【正文】
。039。139。039。039。139。039。139。039。039。139。039。039。139。039。039。139。039。139。039。039。139。039。139。139。039。139。039。039。139。039。039。039。139。139。039。039。139。039。139。039。139。139。039。039。139。039。039。139。139。139。039。039。139。039。139。139。139。139。039。039。 end pencoder。gs:chip select output。 ei:in std_logic。 use 。 end。 b2v_inst6 : shiftr_4 port map (clk = synthesized_wire _8, load = enable, a = a, 61 qout = synthesized_wire _1)。 b2v_inst2 : andl port map (x = synthesized_wire _1, bb = synthesized_wire _2, qt = synthesized_wire _7)。 b2v_inst : shiftl_8 port map(clk = synthesized_wire _8, load = enable, b = b, qout = synthesized_wire _2)。 signal synthesized_wire _7 : std_logic _vector (7 downto 0)。 signal synthesized_wire _4 : std_logic _vector (7 downto 0)。 signal synthesized_wire _1 : std_logic。 end ponent。 b : in std_logic _vector (7 downto 0)。 end ponent。 a : in std_logic _vector (3 downto 0)。 ponent shiftr_4 port (clk : in std_logic。 qx : out std_logic _vector (7 downto 0))。 clr : in std_logic。 end ponent。 bb : in std_logic _vector (7 downto 0)。 end ponent。 en : in std_logic。 end ponent。 b : in std_logic _vector (3 downto 0)。 architecture bdf_type of multiplier44 is ponent shiftl_8 port( clk : in std_logic。 m : out std_logic _vector (7 downto 0))。 a : in std_logic _vector(3 downto 0)。 entity multiplier44 is port( clk : in std_logic。 use 。 end art。 architecture art of enable is begin process(clk,en) begin clock=clk and (not en)。 clock: out std_logic)。 use 。 end art。 end loop。 end。 bb: in std_logic_vector(7 downto 0)。 use 。 end art。 end if。139。 elsif clk39。139。 end。 d: in std_logic_vector(7 downto 0)。 use 。 end art。 sint=aa+bb。amp。 bb=39。amp。 begin aa=39。 architecture art of adder8b is signal sint:std_logic_vector(8 downto 0)。 s: out std_logic_vector(7 downto 0))。 use 。 3) 8 位加法器模塊源程序 library ieee。 end process。 qout(7 downto 0)=q(8 downto 1)。 q(0):=39。139。 elsif clk39。b(3 downto 0)。139。 architecture art of shiftl_8 is begin process(clk,load) variable q: std_logic_vector(8 downto 0)。 qout: buffer std_logic_vector(7 downto 0))。 entity shiftl_8 is port(clk,load:in std_logic。 2) 8 位 左 移寄存器模塊源程序 library ieee。 end process。039。 q(2 downto 0):= q(3 downto 1)。139。 elsif clk39。139。 architecture art of shiftr_4 is begin process(clk,load) variable q: std_logic_vector(3 downto 0):=0000。 qout: out std_logic)。 entity shiftr_4 is port(clk,load:in std_logic。 參考程序如下所示: 子模塊源程序: 1) 4 位右移寄存器模塊源程 序 library ieee。 仿真波形如圖 所示: 56 圖 , 參考 原理圖 如 圖 所示: 圖 仿真波形如圖 所示: 圖 57 4位二進制數相乘,它們的乘積最大值為 1515=225,而一個 8位二進制數能表示的最大數值為 255。 end process。 end if。設定容量 FF else dout=dout1。039。 end if。 then if(dout=11111111)then dout=00000000。 elsif s=39。139。)。then dout=(others=39。 then if clr=39。event and clk=39。 end。s=1 加法計數, s=0 減法計數 din: in std_logic_vector(7 downto 0)。 use 。 仿真波形如圖 所示: 55 圖 : library ieee。 end process。 end if。 then if(dout=255)then dout=00000000。event and clk=39。then dout=00000000。 architecture art of counter_plus is begin process(clk,clr) begin if clr=39。 dout: buffer std_logic_vector(7 downto 0))。 use 。 習題 5 : library ieee。 end process 。 序列數檢測正確,輸出 a else ab = 1011 。 end process 。 end case 。 end if 。 when 4= if din = d(0) then q = 5 。 else q = 0 。 end if 。 when 2= if din = d(2) then q = 3 。 else q = 0 。 end if 。 then 時鐘到來時,判斷并處理當前輸入的位 case q is when 0= if din = d(4) then q = 1 。event and clk=39。 then q = 0 。 5 位待檢測預置數 process( clk, clr ) begin if clr = 39。 54 signal d : std_logic_vector(4 downto 0)。 檢測結果輸出 end schk。 entity schk is port(din, clk, clr : in std_logic。 : library ieee 。 cout=temp。 end if。 end if。 jie=39。039。 else if (temp=0) then temp=10111。139。 else temp=temp+1。 jin=39。139。039。 elsif( clk39。039。139。139。then temp=00000。 begin process(clk,reset,ctrl,follow,cin) begin if reset=39。 end counter_up_down_24。 cout:out std_logic_vector(4 downto 0)。 entity counter_up_down_24 is 53 port(reset,ctrl,follow,clk:in std_logic。 use 。 end maxpld。 end if。139。 p2: process(din,clk) begin if (clk39。 end if。139。 architecture maxpld of dff_latch is signal temp:std_logic。 qout : out std_logic)。 use 。 end architecture archmux3 。 else count = 39。 else count = not bin when sel = 39。 else count = ain xor bin when sel = 39。 else count = ain nand bin when sel = 39。 (c) architecture archmux3 of mux is begin count = ain or bin when sel = 39。 end process mux4_1。xx39。 when 3 = count = not bin。 when 1 = count = ain nand bin。 end if。139。 end if 。139。039。 (b) architecture archmux2 of mux is signal temp_sel : integer range o to 3 。 end process mux4_1。 else count =xx。 elsif sel = 10 then count = ain xor bin。 architecture archmux1 of mux is begin mux4_1: process (ain, bin,sel) begin if sel = 00 then count = ain or bin。 count: out std_logic_vector(1 downto 0))。 entity mux is port( ain, bin: in std_logic_vector(1 downto 0)。 11. 參考程序如下: ( a) library ieee。 end process。 q=q_s。 end if。 nq_s=not nq。139。139。039。139。039。139。139。039。139。039。139。039。139。 begin process(j,k,clk,rst) begin if(clk39。 end。 entity jk is port(j,k,clk,rst: in std_logic。 : 10. 參考程序如下: library ieee。 end ge