Download presentation
Presentation is loading. Please wait.
Published byJanel Snow Modified over 8 years ago
1
Dr. Turki F. Al-Somani VHDL synthesis and simulation
2
2 Combinational logic design A) Problem description y is 1 if a is to 1, or b and c are 1. z is 1 if b or c is to 1, but not both, or if all are 1. D) Minimized output equations 00 0 1 011110 0 1 010 111 a bc y y = a + bc 00 0 1 011110 0 0 101 111 z z = ab + b’c + bc’ a bc C) Output equations y = a'bc + ab'c' + ab'c + abc' + abc z = a'b'c + a'bc' + ab'c + abc' + abc B) Truth table 10111 11011 11111 00101 01001 01110 10010 00000 Inputs abc Outputs yz E) Logic Gates a b c y z
3
3 Sequential logic design A) Problem Description You want to construct a clock divider. Slow down your pre- existing clock so that you output a 1 for every four clock cycles 0 12 3 x=0 x=1 x=0 a=1 a=0 B) State DiagramC) Implementation Model Combinational logic State register a x I0 I1 Q1 Q0 D) State Table (Moore-type) 10111 11011 11100 00101 01001 01110 10010 00000 Inputs Q1Q0a Outputs I1I0 1 0 0 0 x Given this implementation model Sequential logic design quickly reduces to combinational logic design
4
4 Sequential logic design (cont.) 0 0 1 Q1Q0 I1 I1 = Q1’Q0a + Q1a’ + Q1Q0’ 01 1 1 010 0011 10 a 01 0 0 0 101 1 00 01 11 a 1 10 I0 Q1Q0 I0 = Q0a’ + Q0’a 0 1 00 0 1 1 0 0 00 01 11 10 x = Q1Q0 x 0 1 0 a Q1Q0 E) Minimized Output EquationsF) Combinational Logic a Q1 Q0 I0 I1 x
5
5 Custom single-purpose processor basic model controller and datapath controllerdatapath … … external control inputs external control outputs … external data inputs … external data outputs datapath control inputs datapath control outputs … … a view inside the controller and datapath controllerdatapath … … state register next-state and control logic registers functional units
6
6 Example: greatest common divisor GCD (a) black-box view x_i y_i d_o go_i 0: int x, y; 1: while (1) { 2: while (!go_i); 3: x = x_i; 4: y = y_i; 5: while (x != y) { 6: if (x < y) 7: y = y - x; else 8: x = x - y; } 9: d_o = x; } (b) desired functionality y = y -x 7: x = x - y 8: 6-J: x!=y 5: !(x!=y) x<y!(x<y) 6: 5-J: 1: 1 !1 x = x_i 3: y = y_i 4: 2: 2-J: !go_i !(!go_i) d_o = x 1-J: 9: (c) state diagram First create algorithm Convert algorithm to “complex” state machine Known as FSMD: finite- state machine with datapath Can use templates to perform such conversion
7
7 Creating the datapath Create a register for any declared variable Create a functional unit for each arithmetic operation Connect the ports, registers and functional units Based on reads and writes Use multiplexors for multiple sources Create unique identifier for each datapath component control input and output y = y -x 7: x = x - y 8: 6-J: x!=y 5: !(x!=y) x<y!(x<y) 6: 5-J: 1: 1 !1 x = x_i 3: y = y_i 4: 2: 2-J: !go_i !(!go_i) d_o = x 1-J: 9: subtractor 7: y-x8: x-y5: x!=y6: x<y x_iy_i d_o 0: x0: y 9: d n-bit 2x1 x_sel y_sel x_ld y_ld x_neq_y x_lt_y d_ld < 5: x!=y != Datapath
8
8 Creating the controller’s FSM Same structure as FSMD Replace complex actions/conditions with datapath configurations y = y -x 7: x = x - y 8: 6-J: x!=y 5: !(x!=y) x<y!(x<y) 6: 5-J: 1: 1 !1 x = x_i 3: y = y_i 4: 2: 2-J: !go_i !(!go_i) d_o = x 1-J: 9: y_sel = 1 y_ld = 1 7: x_sel = 1 x_ld = 1 8: 6-J: x_neq_y 5: !x_neq_y x_lt_y!x_lt_y 6: 5-J: d_ld = 1 1-J: 9: x_sel = 0 x_ld = 1 3: y_sel = 0 y_ld = 1 4: 1: 1 !1 2: 2-J: !go_i !(!go_i) go_i 0000 0001 0010 0011 0100 0101 0110 01111000 1001 1010 1011 1100 Controller subtractor 7: y-x8: x-y5: x!=y6: x<y x_iy_i d_o 0: x0: y 9: d n-bit 2x1 x_sel y_sel x_ld y_ld x_neq_y x_lt_y d_ld < 5: x!=y != Datapath
9
9 Splitting into a controller and datapath y_sel = 1 y_ld = 1 7: x_sel = 1 x_ld = 1 8: 6-J: x_neq_y=1 5: x_neq_y=0 x_lt_y=1x_lt_y=0 6: 5-J: d_ld = 1 1-J: 9: x_sel = 0 x_ld = 1 3: y_sel = 0 y_ld = 1 4: 1: 1 !1 2: 2-J: !go_i !(!go_i) go_i 0000 0001 0010 0011 0100 0101 0110 01111000 1001 1010 1011 1100 Controller Controller implementation model y_sel x_sel Combinational logic Q3Q0 State register go_i x_neq_y x_lt_y x_ld y_ld d_ld Q2Q1 I3I0I2I1 subtractor 7: y-x8: x-y5: x!=y6: x<y x_iy_i d_o 0: x0: y 9: d n-bit 2x1 x_sel y_sel x_ld y_ld x_neq_y x_lt_y d_ld < 5: x!=y != (b) Datapath
10
10 Controller state table for the GCD example InputsOutputs Q3Q2Q1Q0x_neq _y x_lt_ y go_iI3I2I1I0x_sely_selx_ldy_ldd_ld 0000***0001XX000 0001**00010XX000 0001**10011XX000 0010***0001XX000 0011***01000X100 0100***0101X0010 01010**1011XX000 01011**0110XX000 0110*0*1000XX000 0110*1*0111XX000 0111***1001X1010 1000***10011X100 1001***1010XX000 1010***0101XX000 1011***1100XX001 1100***0000XX000 1101***0000XX000 1110***0000XX000 1111***0000XX000
11
11 Completing the GCD custom single- purpose processor design We finished the datapath We have a state table for the next state and control logic All that’s left is combinational logic design This is not an optimized design, but we see the basic steps … … a view inside the controller and datapath controllerdatapath … … state register next-state and control logic registers functional units
12
VHDL Part 3 12 Example Consider the following algorithm that gives the maximum of two numbers. 0: int x, y, z; 1: while (1) { 2: while (!start); 3: x = A; 4: y = B; 5: if (x >= y) 6: z = x; else 7: z = y; }
13
VHDL Part 3 13 Example – Cont. Now, consider the following VHDL code that gives the maximum of two numbers. ----------------------------------------------------------------------------------------- entity MAX is generic(size: integer:=4); port( clk, reset, start: in std_logic; x_i, y_i :in std_logic_vector(size-1 downto 0); z_o: out std_logic_vector(size-1 downto 0)); end MAX; architecture behavioral of MAX is type STATE_TYPE is (S0, S1, S2, S3, S4); signal Current_State, Next_State: STATE_TYPE; signal x, y, mux : std_logic_vector (size-1 downto 0):= (others => '0'); signal z_sel, x_ld, y_ld, z_ld : std_logic := '0'; begin
14
VHDL Part 3 14 Example – Cont. ----------------------------------------------- Reg_x: process (CLK) begin if (CLK'event and CLK='1') then if reset='1' then x '0'); else if (x_ld='1') then x <= x_i; end if; end process; ----------------------------------------------- Reg_y: process (CLK) begin if (CLK'event and CLK='1') then if reset='1' then y '0'); else if (y_ld='1') then y <= y_i; end if; end process; ----------------------------------------------- Reg_z_o:process (CLK) begin if (CLK'event and CLK='1') then if reset='1' then z_o '0'); else if (z_ld='1') then z_o <= mux; end if; end process; ----------------------------------------------- Multiplexer: process (x, y, z_sel) begin if (z_sel='0') then mux <= x; elsif (z_sel='1') then mux <= y; end if; end process; -----------------------------------------------
15
VHDL Part 3 15 Example – Cont. ----------------------------------------------- SYNC_PROC: process (CLK, RESET) begin if (RESET='1') then Current_State <= S0; elsif (CLK'event and CLK = '1') then Current_State <= Next_State; end if; end process; ----------------------------------------------- COMB_PROC: process (Current_State, start, x, y, z_sel) begin case Current_State is -------------------------- when S0 =>-- idle if (start='1') then Next_State <= S1; else Next_State <= S0; end if; -------------------------- when S1 =>-- x = x_i & y = y_i x_ld <= '1'; y_ld <= '1'; z_ld <= '0' Next_State <= S2; -------------------------- when S2 =>-- x ≥ y x_ld <= '0'; y_ld <= '0'; if (x >= y ) then Next_State <= S3; else Next_State <= S4; end if; -------------------------- when S3 =>-- z = x z_sel <= '0'; z_ld<=’1’; Next_State <= S0; -------------------------- when S4 =>-- z = y z_sel <= '1'; z_ld<=’1’; Next_State <= S0; end case; end process; ----------------------------------------------
16
VHDL Part 3 16 Now, What’s Next ?!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.