Verilog Lecture Gandhi Puvvada, USC always statements, Coding a Flip-Flop. blocking and non-blocking assignments. Copyright 2008 Gandhi Puvvada 1

Size: px
Start display at page:

Download "Verilog Lecture Gandhi Puvvada, USC always statements, Coding a Flip-Flop. blocking and non-blocking assignments. Copyright 2008 Gandhi Puvvada 1"

Transcription

1 EE201L and EE560 Verilog Lecture by Gandhi Puvvada, USC always statements, t t Coding a Flip-Flop Counters, Basics of Data Path, blocking and non-blocking assignments Copyright 2008 Gandhi Puvvada 1

2 always statement for clocked logic Flip-Flops, Counters, State Machines, Data Registers,... In short, any clocked logic Logic with no reset Clk) begin : NO_RESET // statements; Copyright 2008 Gandhi Puvvada 2

3 asynchronous reset Clk, posedge Reset) begin : ASYNC_R if (Reset) // statements; else // statements; synchronous reset Clk ) begin : SYNC_ R if (Reset) // statements; else // statements; Copyright 2008 Gandhi Puvvada 3

4 asynchronous reset Clk, negedge Reset) begin : ASYNC_R if (~Reset) // statements; else // statements; synchronous reset Clk ) begin : SYNC_ R if (~Reset) // statements; else // statements; Copyright 2008 Gandhi Puvvada 4

5 Flip-Flop coding Q_no_r = FF with no reset at all Q_async_r = FF with asynchronous reset Q_sync_r = FF with synchronous reset Q_no_r_de = FF with Data Enable but no reset at all (suitable for data registers) Q_async_r_de = FF with asynchronous reset with Data Enable Q_sync_r_de = FF with synchronous reset with Data Enable Q_bad_r = The BAD coding results in treating the RESET as a Data-enable control. Q_bad_r_made_good = BAD coding fixed! Copyright 2008 Gandhi Puvvada 5

6 Q_no_r = FF with no reset at all Clk) begin : FF_NO_R Q_no_r <= D; Copyright 2008 Gandhi Puvvada 6

7 Q_no_r = FF with no reset at all Copyright 2008 Gandhi Puvvada 7

8 RTL schematic Copyright 2008 Gandhi Puvvada 8

9 Q_async_r = FF with asynchronous reset Clk, posedge Reset) begin : FF_ ASYNC_ R if (Reset) Q_async_r <= 1'b0; else Q_async_r <= D; Copyright 2008 Gandhi Puvvada 9

10 Q_async_r = FF with asynchronous reset Copyright 2008 Gandhi Puvvada 10

11 Q_sync_r = FF with synchronous reset Clk) begin : FF_ SYNC_ R if (Reset) Q_sync_r <= 1'b0; else Q_sync_r <= D; Copyright 2008 Gandhi Puvvada 11

12 Q_no_r_de = FF with Data Enable but no reset at all (suitable for data registers) Clk) begin : FF_NO_R_DE if (de) Q_no_r_de <= D; Copyright 2008 Gandhi Puvvada 12

13 Q_async_r_de = FF with asynchronous reset with Data Enable Clk, posedge Reset) begin : FF_ASYNC_R_DE if (Reset) Q_async_r_de <= 1'b0; else if (de) Q_async_r_de <= D; Copyright 2008 Gandhi Puvvada 13

14 Q_async_r_de = FF with asynchronous reset with Data Enable Copyright 2008 Gandhi Puvvada 14

15 Q_sync_r_de = FF with synchronous reset with Data Enable Clk) begin : FF_SYNC_R_DE if (Reset) Q_sync_r_de <= 1'b0; else if (de) Q_sync_r_de <= D; Copyright 2008 Gandhi Puvvada 15

16 Q_bad_r = The BAD coding results in treating the RESET as a Data-enable control Clk, posedge Reset) begin : FF_BAD_R if (Reset) ; // nothing to do else Q_bad_r <= D; Copyright 2008 Gandhi Puvvada 16

17 Q_bad_r = The BAD coding results in treating the RESET as a Data-enable control Copyright 2008 Gandhi Puvvada 17

18 Q_bad_r = The BAD coding results in treating the RESET as a Data-enable control Copyright 2008 Gandhi Puvvada 18

19 Q_bad_r_made_good = BAD coding fixed! Clk, posedge Reset) begin : FF_BAD_R_MADE_GOOD if (Reset) Q_bad_r_made_good <= 1'bX ; // tell XST that you do not // care what happens during // the reset else Q_bad_r_made_good <= D; Copyright 2008 Gandhi Puvvada 19

20 Q_bad_r_made_good = BAD coding fixed! Copyright 2008 Gandhi Puvvada 20

21 Synchronous counter with CLR, LOAD, and EN controls Mo st Significant A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Mux 3 I00 I01 I02 Y0 I10 I11 I12 Y1 Y2 S EN Least Significant BA0 BA1 BA2 Mux I00 I01 I02 Y0 I10 I11 I12 Y1 Y2 S Register 2 Mux1 Q0* D Q Q0 I00 I01 Q1* Q1 I02 Y0 Y1 D Q 0 I10 Y2 I11 Q2* Q2 0 I12 S D Q LOAD CLR CLK Copyright 2008 Gandhi Puvvada 21

22 74LS163A Synchronous counter Copyright 2008 Gandhi Puvvada 22

23 Gradual development of counter A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Register Q0* Q0 D Q Q1* Q1 D Q Q2* Q2 D Q CLK I00 I01 I02 Mux3 Y0 Y1 Y2 I10 I11 I12 S EN BA0 BA1 BA2 Mux 2 I00 I01 I02 Y0 I10 I11 I12 Y1 Y2 S LOAD 0 Mux 1 I00 I01 I02 Y0 Y1 I10 Y2 I11 I12 S CLR Copyright 2008 Gandhi Puvvada 23

24 Basic idea in datapath design in RTL: intercept and inject Free running counter i <= i + 1; A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Register Q0* Q0 D Q Q1* Q1 D Q Q2* Q2 D Q CLK I00 I01 I02 I10 I11 I12 Mux 3 Y0 Y1 Y2 S EN BA0 BA1 BA2 I00 I01 I02 I10 I11 I12 Mux Y0 Y1 Y2 S 2 LOAD 0 I00 I01 I02 I10 I11 I12 Mux Y0 Y1 Y2 S 1 CLR Copyright 2008 Gandhi Puvvada 24

25 Counter with CLR control if f(c (CLR) i <= 3 b000; else i <= i + 1; A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Register Q0* Q0 D Q Q1* Q1 D Q Q2* Q2 D Q CLK I00 I01 I02 I10 I11 I12 Mux 3 Y0 Y1 Y2 S EN BA0 BA1 BA2 I00 I01 I02 I10 I11 I12 Mux Y0 Y1 Y2 S 2 LOAD 0 I00 I01 I02 I10 I11 I12 Mux Y0 Y1 Y2 S 1 CLR Copyright 2008 Gandhi Puvvada 25

26 Counter with CLR and LOAD controls if (CLR) i <= 3 b000; else if (LOAD) i <= {BA2, BA1, BA0}; else i <= i + 1; A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Register Q0* Q0 D Q Q1* Q1 D Q Q2* Q2 D Q CLK I00 I01 I02 I10 I11 I12 Mux 3 Y0 Y1 Y2 S EN BA0 BA1 BA2 I00 I01 I02 I10 I11 I12 Mux Y0 Y1 Y2 S 2 LOAD 0 I00 I01 I02 I10 I11 I12 Mux Y0 Y1 Y2 S 1 CLR Copyright 2008 Gandhi Puvvada 26

27 Counter with CLR, LOAD, and EN controls if (CLR) i <= 3 b000; else if (LOAD) i <= {BA2, BA1, BA0}; else if (EN) i <= i + 1; A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Register Q0* Q0 D Q Q1* Q1 D Q Q2* Q2 D Q CLK I00 I01 I02 I10 I11 I12 Mux 3 Y0 Y1 Y2 S EN BA0 BA1 BA2 I00 I01 I02 I10 I11 I12 Mux Y0 Y1 Y2 S 2 LOAD 0 I00 I01 I02 I10 I11 I12 Mux Y0 Y1 Y2 S 1 CLR Copyright 2008 Gandhi Puvvada 27

28 Counter with CLR, LOAD, and EN controls if (CLR) i <= 3 b000; else if (LOAD) i <= {BA2, BA1, BA0}; else if (EN) i<=i+1; i else i <= i; A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Register Q0* Q0 D Q Q1* D Q Q1 Q2* Q2 D Q CLK Mux3 I00 I01 I02 Y0 Y1 I10 Y2 I11 I12 S EN BA0 BA1 BA2 Mux2 I00 I01 I02 Y0 Y1 I10 Y2 I11 I12 S LOAD 0 Mux1 I00 I01 I02 Y0 Y1 I10 Y2 I11 I12 S CLR Copyright 2008 Gandhi Puvvada 28

29 Is this CLR control a synchronous clear control or an asynchronous clear control? Mo st Significant A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Mux 3 I00 I01 I02 Y0 Y1 I10 Y2 I11 I12 S EN Least Significant BA0 BA1 BA2 I10 I11 I12 Mux I00 I01 I02 Y0 Y1 Y2 S Register 2 Mux1 Q0* D Q Q0 I00 I01 Q1* Q1 I02 Y0 Y1 D Q 0 I10 Y2 I11 Q2* Q2 0 I12 S D Q LOAD CLR CLK Copyright 2008 Gandhi Puvvada 29

30 How do we describe this counter in Verilog HDL? Structurally emulating the gate-level logic schematic of 74LS163A? Behaviorally based on the MSI level function design diagram? Mo st Significant Least Significant Adder Regist er Mux3 Mux2 Mux1 Q0* Q0 A0 D Q A1 I00 I00 I00 A2 I01 I01 I01 Q1* Q1 I02 Y0 I02 Y0 I02 Y0 1 B0 Y1 Y1 Y1 D Q 0 B1 S0 I10 Y2 BA0 I10 Y2 0 I10 Y2 0 B2 S1 I11 BA1 I11 I11 S2 Q2* Q2 I12 S BA2 I12 S 0 I12 S D Q EN LOAD CLR CLK Copyright 2008 Gandhi Puvvada 30

31 Ok, we all agree -- behaviorally So, shall we describe three muxes and one incrementer and a register? Mo st Significant A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Mux 3 I00 I01 I02 Y0 Y1 I10 Y2 I11 I12 S EN Least Significant BA0 BA1 BA2 I10 I11 I12 Mux I00 I01 I02 Y0 Y1 Y2 S Register 2 Mux1 Q0* D Q Q0 I00 I01 Q1* Q1 I02 Y0 Y1 D Q 0 I10 Y2 I11 Q2* Q2 0 I12 S D Q LOAD CLR CLK Copyright 2008 Gandhi Puvvada 31

32 No! 5 separate items and their interconnection is not quite readable! Mo st Significant A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Mux 3 I00 I01 I02 Y0 Y1 I10 Y2 I11 I12 S EN Least Significant BA0 BA1 BA2 I10 I11 I12 Mux I00 I01 I02 Y0 Y1 Y2 S Register 2 Mux1 Q0* D Q Q0 I00 I01 Q1* Q1 I02 Y0 Y1 D Q 0 I10 Y2 I11 Q2* Q2 0 I12 S D Q LOAD CLR CLK Copyright 2008 Gandhi Puvvada 32

33 An if statement in a clocked always block! Mo st Significant A0 A1 A2 B0 B1 B2 Adder S0 S1 S2 Mux 3 I00 I01 I02 Y0 Y1 I10 Y2 I11 I12 S EN Least Significant BA0 BA1 BA2 I10 I11 I12 Mux I00 I01 I02 Y0 Y1 Y2 S Register 2 Mux1 Q0* D Q Q0 I00 I01 Q1* Q1 I02 Y0 Y1 D Q 0 I10 Y2 I11 Q2* Q2 0 I12 S D Q LOAD CLR CLK Copyright 2008 Gandhi Puvvada 33

34 Closest code Q_sync_r_de = FF with synchronous reset with Data Enable Clk) begin : FF_SYNC_R_DE if (Reset) Q_sync_r_de <= 1'b0; else if (de) Q_sync_r_de <= D; Copyright 2008 Gandhi Puvvada 34

35 Coding of a counter with synchronous CLR, and synchronous LOAD, and EN CLK, posedge CLR) begin : COUNTER if (CLR) Count <= 3'b000; else if (LOAD) Count <= Load_input; else if (EN) Count <= Count +1; Copyright 2008 Gandhi Puvvada 35

36 Coding of a counter with asynchronous CLR, and synchronous LOAD, and EN CLK, posedge CLR) begin : COUNTER if (CLR) Count <= 3'b000; else if (LOAD) Count <= Load_input; else if (EN) Count <= Count +1; Copyright 2008 Gandhi Puvvada 36

37 blocking and non-blocking assignments in procedural blocks Copyright 2008 Gandhi Puvvada 37

38 blocking assignments Copyright 2008 Gandhi Puvvada 38

39 blocking assignments Copyright 2008 Gandhi Puvvada 39

40 blocking assignments Copyright 2008 Gandhi Puvvada 40

41 blocking assignments Copyright 2008 Gandhi Puvvada 41

42 non-blocking assignments Copyright 2008 Gandhi Puvvada 42

43 non-blocking assignments Copyright 2008 Gandhi Puvvada 43

44 non-blocking assignments Copyright 2008 Gandhi Puvvada 44

45 non-blocking assignments Copyright 2008 Gandhi Puvvada 45

46 blocking and non-blocking assignments in procedural blocks Copyright 2008 Gandhi Puvvada 46

47 Consider a RIGHT-SHIFT register. Copyright 2008 Gandhi Puvvada 47

48 RIGHT-SHIFT register Copyright 2008 Gandhi Puvvada 48

49 RIGHT-SHIFT register Copyright 2008 Gandhi Puvvada 49

50 RIGHT-SHIFT register Copyright 2008 Gandhi Puvvada 50

51 RIGHT-SHIFT register Copyright 2008 Gandhi Puvvada 51

52 Copyright 2008 Gandhi Puvvada 52

53 Copyright 2008 Gandhi Puvvada 53

54 Copyright 2008 Gandhi Puvvada 54

55 Copyright 2008 Gandhi Puvvada 55

56 Copyright 2008 Gandhi Puvvada 56

57 RIGHT-SHIFT register Copyright 2008 Gandhi Puvvada 57

58 RIGHT-SHIFT register Copyright 2008 Gandhi Puvvada 58

59 TIMING Design avoids race Copyright 2008 Gandhi Puvvada 59

60 TIMING Design avoids race Copyright 2008 Gandhi Puvvada 60

61 Static ti Timing i Designer (in synthesis and implementation tools) performs millions of these timing checks to ensure that there are no RACE conditions! Copyright 2008 Gandhi Puvvada 61

62 Static Timing Designer. But then, during initial behavioral simulation, we do not state any delays in our code! So, our ZERO delay coding will fail?!? Copyright 2008 Gandhi Puvvada 62

63 Yes, that is where the non-blocking assignments with delta-delay save the day! Copyright 2008 Gandhi Puvvada 63

64 RIGHT-SHIFT register QC <= QB; QB <= QA; QA <= Sin; QC = QB; QB = QA; QA = Sin; QA <= Sin; QB <= QA; QC <= QB; QA = Sin; QB = QA; QC = QB; Copyright 2008 Gandhi Puvvada 64

65 RIGHT-SHIFT register QC <= QB; QB <= QA; QA <= Sin; QC = QB; QB = QA; QA = Sin; QA <= Sin; QB <= QA; QC <= QB; QA = Sin; QB = QA; QC = QB; Copyright 2008 Gandhi Puvvada 65

66 RIGHT-SHIFT register QC <= QB; QB <= QA; QA <= Sin; QC = QB; QB = QA; QA = Sin; QA <= Sin; QB <= QA; QC <= QB; QA = Sin; QB = QA; QC = QB; Copyright 2008 Gandhi Puvvada 66

67 RIGHT-SHIFT register CIRCULAR-SHIFT register QC = QB; QB = QA; QA = Sin; QC = QB; QB = QA; QA = QC; QC <= QB; QB <= QA; QA <= QC; Does any of the two work? Copyright 2008 Gandhi Puvvada 67

68 CIRCULAR-SHIFT register QC = QB; QB = QA; QA = QC; QC = QB; QB = QA; QA = QC; QC <= QB; QB <= QA; QA <= QC; Does any of the two work? Copyright 2008 Gandhi Puvvada 68

69 Conclusion on non-blocking assignment usage: Use it for assigning to physical registers In any real system, there e are hundreds of registers s updating on the same clock tick. Each register (through its NSL) should decide what to do (what value to acquire) based on the current state t (before the next clock edge) of other registers (including itself). Hence, use non-blocking assignments to assign a value to a register so that the new value appears after delta-t and does not cause any race condition. Copyright 2008 Gandhi Puvvada 69

70 Then, when do we use blocking assignments? For intermediate variables, (and in combinational logic) Copyright 2008 Gandhi Puvvada 70

71 intermediate variables in multi-level l l combinational logic Example problem: Given four numbers P, Q, X, Y find the smallest value and output t it as R (the result). One can use the conditional select operator in the continuous assign statement or in a procedural assignment statement, but the if statement (in a procedural block) is much more readable. Copyright 2008 Gandhi Puvvada 71

72 intermediate variables in multi-level combinational logic Without intermediate ed variables ab //conditional select operator sel? True : false assign R_assign1 = ( ((P < Q)? P : Q ) < ((X < Y)? X : Y ) )? ((P < Q)? P : Q ) : ((X < Y)? X : Y ); Copyright 2008 Gandhi Puvvada 72

73 intermediate variables in multi-level combinational logic With wire type intermediate variables (Data Flow modeling) //conditional select operator sel? True : false assign small_pq_wire = (P < Q)? P : Q ; assign small_xy_wire = (X < Y)? X : Y ; assign R_assign2 = (small_pq_wire < small_xy_wire)? small_pq_wire : small_xy_wire ; Copyright 2008 Gandhi Puvvada 73

74 intermediate variables in multi-level combinational logic With reg type intermediate variables (behavioral modeling) if (P < Q) small_pq_reg = P; begin : SMALL_ALWAYS else small_pq_reg = Q ; // local reg variables if (X < Y) reg [1:0] small_pq_reg; small_xy_reg = X; reg [1:0] small_xy_reg; else small_xy_reg = Y ; if (small_pq_reg < small_xy_reg) R_always = small_pq_reg; else R_always = small_xy_reg ; Copyright 2008 Gandhi Puvvada 74

75 Final (final, not intermediate) assignment in combinational logic can be either blocking or non-blocking. As a thumb rule, we can use blocking assignments uniformly for describing combinational logic. if (P < Q) small_pq_reg = P; else small_pq_reg = Q ; if (X < Y) small_xy_reg = X; else small_xy_reg = Y ; if (small_pq_reg < small_xy_reg) R_always = small_pq_reg; else R_always = small_xy_reg ; Copyright 2008 Gandhi Puvvada 75

76 blocking and non-blocking assignments in clocked always blocks For physical registers, use non-blocking assignments only to prevent race condition and to prevent discrepancy between simulation and synthesis For producing values to be registered, if you use intermediate variables, then use blocking assignments to produce them. Copyright 2008 Gandhi Puvvada 76

77 blocking and non-blocking assignments in clocked always blocks Copyright 2008 Gandhi Puvvada 77

78 blocking and non-blocking assignments in clocked always blocks (posedge CLK) begin : NSL_SM_example D = D1 & D2; Q <= D; (posedge CLK) begin : NSL_SM_example D <= D1 & D2; Q = D; Copyright 2008 Gandhi Puvvada 78

79 blocking and non-blocking assignments in clocked always blocks (posedge CLK) begin : NSL_SM_example D = D1 & D2; (posedge CLK) begin : NSL_SM_example D <= D1 & D2; Q <= D; Q = D; Some think that both are OK. Other clocked always blocks may have Q on the RHS. You do not want to cause RACE condition nor simulation synthesis discrepancy. Copyright 2008 Gandhi Puvvada 79

80 Golden rule: Every non-blocking assignment in a clocked processes will result in a physical register! (posedge CLK) begin : NSL_SM_example D=D1&D2; D1 D2; Q <= D; (posedge CLK) begin : NSL_SM_example _ D <= D1 & D2; Q <= D; Copyright 2008 Gandhi Puvvada 80

81 intermediate variables? Then, do not try to read them before you assign to them! Otherwise you get extra registers! (posedge CLK) begin : NSL_SM_example D=D1&D2; D1 D2; Q <= D; (posedge CLK) begin : NSL_SM_example Q <= D; D=D1&D2; D1 D2; Copyright 2008 Gandhi Puvvada 81

82 intermediate variables in a clocked block? Then, treat them as local and do not reference them from outside! (posedge CLK) begin : NSL_SM_example D = D1 & D2; Q <= D; (posedge CLK) begin : NSL_SM_example _ Q_inverted_D <= ~ D; Copyright 2008 Gandhi Puvvada 82

83 If you really wanted this hardware, then code it as.. (posedge CLK) begin : NSL_SM_example (posedge CLK) begin : NSL_SM_example D = D1 & D2; Q <= D; D = D1 & D2; DR <= D; Q<=D; (posedge CLK) begin : NSL_SM_example Q_inverted_D <= ~ D; always (posedge CLK) begin : NSL_SM_example Q_inverted_D <= ~ DR; Copyright 2008 Gandhi Puvvada 83

84 If you wanted this hardware, then code all NSL and both registers in one always block or code the NSL separately in a combinational block. (posedge CLK) begin : NSL_SM_example D = D1 & D2; Q <= D; Q_inverted_D <= ~ D; assign D = D1 & D2; Separate NSL (posedge CLK) begin : SM_example Q <= D; Q_inverted_D <= ~ D; Copyright 2008 Gandhi Puvvada 84

85 If D is an intermediate variable and you do not want anyone to access it by mistake, then restrict its visibility (posedge CLK) begin : NSL_SM_example reg D; // local declaration D = D1 & D2; Q <= D; Copyright 2008 Gandhi Puvvada 85

86 Can you code all this in one always clocked block? Copyright 2008 Gandhi Puvvada 86

87 always (posedge CLK) C ) begin : SM_OFL_example Q1 <= D1; Q2 <= D2; EN <= Q1 & Q2; Copyright 2008 Gandhi Puvvada 87

88 (posedge CLK) begin : SM_OFL_example Q1 <= D1; Q2 <= D2; EN <= Q1 & Q2; Any object (such as EN here) assigned in the clocked always block, irrespective of whether it is assigned using a blocking assignment operator or non-blocking assignment operator, will result in a physical register, if it is referenced from outside of that block. If it is not referenced (referenced = read, placed on the RHS) from outside or inside, the synthesis or the implementation tool will treat it as a waste and will remove it. Copyright 2008 Gandhi Puvvada 88

89 What hardware is inferred by this? (posedge CLK) begin : SM_ OFL_ example Q1 <= D1; Q2 <= D2; EN = Q1 & Q2; if (EN) Q3 <= D3; Copyright 2008 Gandhi Puvvada 89

90 (posedge CLK) begin : SM_ OFL_ example Q1 <= D1; Q2 <= D2; EN = Q1 & Q2; if (EN) Q3 <= D3; hardware inferred Copyright 2008 Gandhi Puvvada 90

91 which of the two codes infers the hardware below? (posedge CLK) begin : SM_OFL_example_1A Q1 <= D1; Q2 <= D2; (posedge CLK) begin : SM_OFL_example_1B EN = Q1 & Q2; if (EN) Q3 <= D3; (posedge CLK) begin : SM_OFL_example_1A Q1 <= D1; Q2 <= D2; EN = Q1 & Q2; (posedge CLK) begin : SM_OFL_example_1B if (EN) Q3 <= D3; Copyright 2008 Gandhi Puvvada 91

92 which of the two codes infers the hardware below? (posedge CLK) begin : SM_OFL_example_1A Q1 <= D1; Q2 <= D2; (posedge CLK) begin : SM_OFL_example_1B EN = Q1 & Q2; if (EN) Q3 <= D3; (posedge CLK) begin : SM_OFL_example_1A Q1 <= D1; Q2 <= D2; EN = Q1 & Q2; (posedge CLK) begin : SM_OFL_example_1B if (EN) Q3 <= D3; Copyright 2008 Gandhi Puvvada 92

93 Then what hardware is inferred by this code? (posedge CLK) begin : SM_OFL_example_1A Q1 <= D1; Q2 <= D2; EN = Q1 & Q2; (posedge CLK) begin : SM_OFL_example_1B if (EN) Q3 <= D3; Copyright 2008 Gandhi Puvvada 93

94 Then what hardware is inferred by this code? registered EN Note that, so far as the hardware inferred or the simulation behavior exhibited, it does not matter whether we used blocking or non-blocking assignment operator here. Both simulation and synthesis tool designers treat the EN referred to in the bottom clocked always block as a registered EN. The tool designers interpret an inappropriate (but syntactically correct) blocking assignment to EN (which is conveyed to another always block) as a nonblocking assignment and proceed with simulation or synthesis. So the two concerns ( discrepancy between simulation and synthesis and creation of race condition elsewhere ) expressed in slides 66/102, 67/102, 76/102, 79/102 are not real concerns, however, we still need to follow the coding recommations as a good engineering practice. (posedge CLK) begin : SM_OFL_example_1A Q1 <= D1; Q2 <= D2; EN = Q1 & Q2; // inappropriate = (posedge CLK) begin : SM_OFL_example_1B if (EN) Q3 <= D3; EN from the top clocked block is referred to here Copyright 2008 Gandhi Puvvada 94

95 What if the 2 nd always block is combinational? (posedge CLK) begin : SM_OFL_example_1A Q1 <= D1; Q2 <= D2; EN = Q1 & Q2; (EN) begin : SM_OFL_example_1B EN_bar <= ~ EN; Copyright 2008 Gandhi Puvvada 95

96 What if the 2 nd always block is combinational? (posedge CLK) begin : SM_OFL_example_1A Q1 <= D1; Q2 <= D2; EN = Q1 & Q2; (EN) begin : SM_OFL_example_1B EN_bar <= ~ EN; Copyright 2008 Gandhi Puvvada 96

97 NS SL SM O FL Generalization: Any upstream logic to a register can be called a NSL! Increme enter Reg Subtrac cter X-Re eg Copyright 2008 Gandhi Puvvada 97

98 NSL SM OFL NS SL SNSL, SM, OFL SM FL O SM goes in a clocked always block. Its NSL (the SM s NSL) can be coded along with the SM in the same clocked always block. However, the OFL outputs are purely combinational and should not be coded along with the SM in the clocked always block. OFL should be coded separately in a combinational block (or produced using assign statements). Or if the OFL is feeding into another NSL of another SM, then it can be combined in the coding of that SM under that clocked always block. Copyright 2008 Gandhi Puvvada 98

99 Division between DPU and CU Traditional division between DPU and CU OFL (combinational logic) is in the CU. DPU Division between DPU and CU for HDL coding OFL (combinational logic) is moved to DPU. It is NOT coded explicitly. The OFL is implicit in the DPU s RTL in the CASE statement. DPU X_Reg Y_Reg X_Reg Y_Reg OFL OFL NSL SM Current_State CU SM NSL Current_State CU Copyright 2008 Gandhi Puvvada 99

100 Counter coding Simple, all non-blocking assignments CLK, posedge CLR) begin : COUNTER if (CLR) Count <= 3'b000; else if (LOAD) Count <= Load_ input; else if (EN) Count <= Count +1; Copyright 2008 Gandhi Puvvada 100

101 Counter coding need for a mix of blocking and non-blocking assignments This is a made-up problem. It is a 5-bit truncated UP counter going from 0 to 20 and back to zero. When the JUMP is asserted, the counter should jump to the mid-point M or a little beyond the midpoint M as detailed below. The midpoint M is the middle point between ee the current count and 20. Example: Say, the current count is 12. Distance from 20 is 8. Half is 4. So the mid point M is at 16 (12+4 = 16). But what if the difference is an ODD number? Then you need to jump by either the "floor" or the "ceiling" of the half of the difference deping on whether the difference is less than ten or more than ten respectively. We said, "or a little beyond the mid point M". After calculating the mid point M, a bonus to the jump by a constant of 4 is allowed if this bonus addition does not cause wrapping around (due to going g beyond 20). Examples: So, for the current count of 12, the jump takes you to 20, but, for the current count of 14, the jump takes you only to 17. Copyright 2008 Gandhi Puvvada 101

102 if (jump) begin Q_next = Q; // notice blocking assignment diff = 20 - Q_next; // (20 - Q) also works if (diff[0] == 0) // if the difference is even begin Q_next = Q_next + { 1'b0, diff[4:1] }; else begin if (diff < 10) begin Q_next = Q_next + { 1'b0, diff[4:1] }; else begin Q_next = Q_next + { 1'b0, diff[4:1] } + 1'b1; if ( (20 - Q_next) >= 4) begin Q_next = Q_next + 4; // bonus 4 Q <= Q_next; // notice the non-blocking assignment Copyright 2008 Gandhi Puvvada 102

Digital Integrated Circuits

Digital Integrated Circuits Digital Integrated Circuits Lecture 4 Jaeyong Chung System-on-Chips (SoC) Laboratory Incheon National University BCD TO EXCESS-3 CODE CONVERTER 0100 0101 +0011 +0011 0111 1000 LSB received first Chung

More information

Last Lecture. Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal

Last Lecture. Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal Last Lecture Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal always_comb t = a & b; f = t c; should use = (called

More information

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto Recommed Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto DISCLAIMER: The information contained in this document does NOT contain

More information

Writing Circuit Descriptions 8

Writing Circuit Descriptions 8 8 Writing Circuit Descriptions 8 You can write many logically equivalent descriptions in Verilog to describe a circuit design. However, some descriptions are more efficient than others in terms of the

More information

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog ECE 2300 Digital Logic & Computer Organization Spring 2018 More Sequential Logic Verilog Lecture 7: 1 Announcements HW3 will be posted tonight Prelim 1 Thursday March 1, in class Coverage: Lectures 1~7

More information

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1 FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1 Anurag Dwivedi Digital Design : Bottom Up Approach Basic Block - Gates Digital Design : Bottom Up Approach Gates -> Flip Flops Digital

More information

Chapter 10. Counters (a short discussion)

Chapter 10. Counters (a short discussion) EE2L_ClassNotes_Ch_Counters_transparencies.fm Chapter Counters (a short discussion) ecimal count sequence: Ex: 788, 789, 79,... Ex: 798, 799, 8,... Generalization: 2 Binary count sequence: In a multi-bit

More information

N-input EX-NOR gate. N-output inverter. N-input NOR gate

N-input EX-NOR gate. N-output inverter. N-input NOR gate Hardware Description Language HDL Introduction HDL is a hardware description language used to design and document electronic systems. HDL allows designers to design at various levels of abstraction. It

More information

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits Name: Instructor: Engr. Date Performed: Marks Obtained: /10 Group Members (ID):. Checked By: Date: Experiment # 11 Introduction to Verilog II Sequential Circuits OBJECTIVES: To understand the concepts

More information

a, b sum module add32 sum vector bus sum[31:0] sum[0] sum[31]. sum[7:0] sum sum overflow module add32_carry assign

a, b sum module add32 sum vector bus sum[31:0] sum[0] sum[31]. sum[7:0] sum sum overflow module add32_carry assign I hope you have completed Part 1 of the Experiment. This lecture leads you to Part 2 of the experiment and hopefully helps you with your progress to Part 2. It covers a number of topics: 1. How do we specify

More information

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified.

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified. 1 In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified. I will also introduce the idea of a testbench as part of a design specification.

More information

Synthesizable Verilog

Synthesizable Verilog Synthesizable Verilog Courtesy of Dr. Edwards@Columbia, and Dr. Franzon@NCSU http://csce.uark.edu +1 (479) 575-6043 yrpeng@uark.edu Design Methodology Structure and Function (Behavior) of a Design HDL

More information

Digital Design with FPGAs. By Neeraj Kulkarni

Digital Design with FPGAs. By Neeraj Kulkarni Digital Design with FPGAs By Neeraj Kulkarni Some Basic Electronics Basic Elements: Gates: And, Or, Nor, Nand, Xor.. Memory elements: Flip Flops, Registers.. Techniques to design a circuit using basic

More information

Verilog for Synthesis Ing. Pullini Antonio

Verilog for Synthesis Ing. Pullini Antonio Verilog for Synthesis Ing. Pullini Antonio antonio.pullini@epfl.ch Outline Introduction to Verilog HDL Describing combinational logic Inference of basic combinational blocks Describing sequential circuits

More information

VHDL: RTL Synthesis Basics. 1 of 59

VHDL: RTL Synthesis Basics. 1 of 59 VHDL: RTL Synthesis Basics 1 of 59 Goals To learn the basics of RTL synthesis. To be able to synthesize a digital system, given its VHDL model. To be able to relate VHDL code to its synthesized output.

More information

ECE 551: Digital System *

ECE 551: Digital System * ECE 551: Digital System * Design & Synthesis Lecture Set 5 5.1: Verilog Behavioral Model for Finite State Machines (FSMs) 5.2: Verilog Simulation I/O and 2001 Standard (In Separate File) 3/4/2003 1 Explicit

More information

Verilog Behavioral Modeling

Verilog Behavioral Modeling Verilog Behavioral Modeling Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C. Spring, 2017 ldvan@cs.nctu.edu.tw http://www.cs.nctu.edu.tw/~ldvan/ Source:

More information

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering Verilog Fundamentals Shubham Singh Junior Undergrad. Electrical Engineering VERILOG FUNDAMENTALS HDLs HISTORY HOW FPGA & VERILOG ARE RELATED CODING IN VERILOG HDLs HISTORY HDL HARDWARE DESCRIPTION LANGUAGE

More information

Lecture #2: Verilog HDL

Lecture #2: Verilog HDL Lecture #2: Verilog HDL Paul Hartke Phartke@stanford.edu Stanford EE183 April 8, 2002 EE183 Design Process Understand problem and generate block diagram of solution Code block diagram in verilog HDL Synthesize

More information

In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and

In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and shift registers, which is most useful in conversion between

More information

Verilog For Synthesis

Verilog For Synthesis Coding with always @(...) Coding with always @(...) always This is separate from the @(...) command. In C procedures are executed when called. In Verilog procedures are executed continuously by default.

More information

Design of a Simple Pipeline (RTL Coding)

Design of a Simple Pipeline (RTL Coding) EE457 Computer Systems Organization Lab #7 Part#3 Subparts #3 and #4 Objective Design of a Simple Pipeline (RTL Coding) To understand and appreciate the improved readability provided by RTL coding (Register

More information

Modeling Sequential Circuits in Verilog

Modeling Sequential Circuits in Verilog Modeling Sequential Circuits in Verilog COE 202 Digital Logic Design Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals Presentation Outline Modeling Latches and Flip-Flops Blocking versus

More information

Digital Design Using Verilog EE Final Examination

Digital Design Using Verilog EE Final Examination Name Digital Design Using Verilog EE 4702-1 Final Examination 8 May 2000, 7:30 9:30 CDT Alias Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Exam Total (100 pts) Good Luck! Problem 1: The modules below

More information

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University Digital Circuit Design and Language Datapath Design Chang, Ik Joon Kyunghee University Typical Synchronous Design + Control Section : Finite State Machine + Data Section: Adder, Multiplier, Shift Register

More information

Lecture 3. Behavioral Modeling Sequential Circuits. Registers Counters Finite State Machines

Lecture 3. Behavioral Modeling Sequential Circuits. Registers Counters Finite State Machines Lecture 3 Behavioral Modeling Sequential Circuits Registers Counters Finite State Machines Behavioral Modeling Behavioral Modeling Behavioral descriptions use the keyword always, followed by optional event

More information

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis Jan 31, 2012 John Wawrzynek Spring 2012 EECS150 - Lec05-verilog_synth Page 1 Outline Quick review of essentials of state elements Finite State

More information

2 ( = 46 points) 30 min.

2 ( = 46 points) 30 min. ee457_quiz_fl2010.fm 10/1/10 2 ( 12 10 24 = 46 points) 30 min. State diagram coding in Verilog (you may refer to the Cadence (Esperan) Verilog guide): Consider the following partial flowchart and the corresponding

More information

ECE 4514 Digital Design II. Spring Lecture 13: Logic Synthesis

ECE 4514 Digital Design II. Spring Lecture 13: Logic Synthesis ECE 4514 Digital Design II A Tools/Methods Lecture Second half of Digital Design II 9 10-Mar-08 L13 (T) Logic Synthesis PJ2 13-Mar-08 L14 (D) FPGA Technology 10 18-Mar-08 No Class (Instructor on Conference)

More information

Exp#8: Designing a Programmable Sequence Detector

Exp#8: Designing a Programmable Sequence Detector Exp#8: Designing a Programmable Sequence Detector Objectives Learning how to partition a system into data-path and control unit. Integrating Schematics and Verilog code together Overview In this lab you

More information

An easy to read reference is:

An easy to read reference is: 1. Synopsis: Timing Analysis and Timing Constraints The objective of this lab is to make you familiar with two critical reports produced by the Xilinx ISE during your design synthesis and implementation.

More information

Control and Datapath 8

Control and Datapath 8 Control and Datapath 8 Engineering attempts to develop design methods that break a problem up into separate steps to simplify the design and increase the likelihood of a correct solution. Digital system

More information

Contents. Chapter 9 Datapaths Page 1 of 28

Contents. Chapter 9 Datapaths Page 1 of 28 Chapter 9 Datapaths Page of 2 Contents Contents... 9 Datapaths... 2 9. General Datapath... 3 9.2 Using a General Datapath... 5 9.3 Timing Issues... 7 9.4 A More Complex General Datapath... 9 9.5 VHDL for

More information

CAD for VLSI Design - I. Lecture 21 V. Kamakoti and Shankar Balachandran

CAD for VLSI Design - I. Lecture 21 V. Kamakoti and Shankar Balachandran CAD for VLSI Design - I Lecture 21 V. Kamakoti and Shankar Balachandran Overview of this Lecture Understanding the process of Logic synthesis Logic Synthesis of HDL constructs Logic Synthesis What is this?

More information

CSE140L: Components and Design Techniques for Digital Systems Lab

CSE140L: Components and Design Techniques for Digital Systems Lab CSE140L: Components and Design Techniques for Digital Systems Lab Tajana Simunic Rosing Source: Vahid, Katz, Culler 1 Announcements & Outline Lab 4 due; demo signup times listed on the cse140l site Check

More information

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1 Verilog Synthesis Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis Spring 2007 Lec #8 -- HW Synthesis 1 Logic Synthesis Verilog and VHDL started out

More information

Lecture 12 VHDL Synthesis

Lecture 12 VHDL Synthesis CPE 487: Digital System Design Spring 2018 Lecture 12 VHDL Synthesis Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ 07030 1 What is Synthesis?

More information

Register Transfer Level

Register Transfer Level Register Transfer Level Something between the logic level and the architecture level A convenient way to describe synchronous sequential systems State diagrams for pros Hierarchy of Designs The design

More information

DIGITAL SYSTEM DESIGN

DIGITAL SYSTEM DESIGN DIGITAL SYSTEM DESIGN Prepared By: Engr. Yousaf Hameed Lab Engineer BASIC ELECTRICAL & DIGITAL SYSTEMS LAB DEPARTMENT OF ELECTRICAL ENGINEERING Digital System Design 1 Name: Registration No: Roll No: Semester:

More information

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis Logic Synthesis Verilog and VHDL started out as simulation languages, but quickly people wrote programs to automatically convert Verilog code into low-level circuit descriptions (netlists). EECS150 - Digital

More information

EEL 4783: HDL in Digital System Design

EEL 4783: HDL in Digital System Design EEL 4783: HDL in Digital System Design Lecture 15: Logic Synthesis with Verilog Prof. Mingjie Lin 1 Verilog Synthesis Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for

More information

CSE140L: Components and Design

CSE140L: Components and Design CSE140L: Components and Design Techniques for Digital Systems Lab Tajana Simunic Rosing Source: Vahid, Katz, Culler 1 Grade distribution: 70% Labs 35% Lab 4 30% Lab 3 20% Lab 2 15% Lab 1 30% Final exam

More information

Topics. Midterm Finish Chapter 7

Topics. Midterm Finish Chapter 7 Lecture 9 Topics Midterm Finish Chapter 7 Xilinx FPGAs Chapter 7 Spartan 3E Architecture Source: Spartan-3E FPGA Family Datasheet CLB Configurable Logic Blocks Each CLB contains four slices Each slice

More information

Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill!

Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill! Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill! by Cliff Cummings Sunburst Design, Inc. Abstract -------- One of the most misunderstood constructs in the Verilog language is the

More information

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis EECS150 - Digital Design Lecture 10 Logic Synthesis September 26, 2002 John Wawrzynek Fall 2002 EECS150 Lec10-synthesis Page 1 Logic Synthesis Verilog and VHDL stated out as simulation languages, but quickly

More information

ENEE245 Digital Circuits and Systems Lab Manual

ENEE245 Digital Circuits and Systems Lab Manual ENEE245 Digital Circuits and Systems Lab Manual Department of Engineering, Physical & Computer Sciences Montgomery College Modified Fall 2017 Copyright Prof. Lan Xiang (Do not distribute without permission)

More information

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis Synthesis of Language Constructs 1 Nets Nets declared to be input or output ports are retained Internal nets may be eliminated due to logic optimization User may force a net to exist trireg, tri0, tri1

More information

Chapter 2 Using Hardware Description Language Verilog. Overview

Chapter 2 Using Hardware Description Language Verilog. Overview Chapter 2 Using Hardware Description Language Verilog CSE4210 Winter 2012 Mokhtar Aboelaze based on slides by Dr. Shoab A. Khan Overview Algorithm development isa usually done in MATLAB, C, or C++ Code

More information

ECE 4514 Digital Design II. Spring Lecture 15: FSM-based Control

ECE 4514 Digital Design II. Spring Lecture 15: FSM-based Control ECE 4514 Digital Design II Lecture 15: FSM-based Control A Design Lecture Overview Finite State Machines Verilog Mapping: one, two, three always blocks State Encoding User-defined or tool-defined State

More information

Spring 2013 EE201L Instructor: Gandhi Puvvada. Time: 7:30-10:20AM SGM124 Total points: Perfect score: Open-Book Open-Notes Exam

Spring 2013 EE201L Instructor: Gandhi Puvvada. Time: 7:30-10:20AM SGM124 Total points: Perfect score: Open-Book Open-Notes Exam Spring 2013 EE201L Instructor: Gandhi Puvvada Final Exam 2 (25%) Date: May 9, 2013, Thursday Name: Open-Book Open-Notes Exam Time: 7:30-10:20AM SGM124 Total points: Perfect score: 1 ( points) min. Memory

More information

Lecture 32: SystemVerilog

Lecture 32: SystemVerilog Lecture 32: SystemVerilog Outline SystemVerilog module adder(input logic [31:0] a, input logic [31:0] b, output logic [31:0] y); assign y = a + b; Note that the inputs and outputs are 32-bit busses. 17:

More information

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis EECS150 - Digital Design Lecture 10 Logic Synthesis February 13, 2003 John Wawrzynek Spring 2003 EECS150 Lec8-synthesis Page 1 Logic Synthesis Verilog and VHDL started out as simulation languages, but

More information

- 1 of 18 - The Verilog Hardware Description Language - A Behavioural View Overview. The Behavioural Model

- 1 of 18 - The Verilog Hardware Description Language - A Behavioural View Overview. The Behavioural Model The Verilog Hardware Description Language - A Behavioural View Overview In this lesson we will Introduce and explore the Verilog behavioural level model. Introduce the behavioural operators. Study the

More information

Lecture 2: Data Types, Modeling Combinational Logic in Verilog HDL. Variables and Logic Value Set. Data Types. Why use an HDL?

Lecture 2: Data Types, Modeling Combinational Logic in Verilog HDL. Variables and Logic Value Set. Data Types. Why use an HDL? Why use an HDL? Lecture 2: Data Types, Modeling Combinational Logic in Verilog HDL Increase digital design engineer s productivity (from Dataquest) Behavioral HDL RTL HDL Gates Transistors 2K 10K gates/week

More information

Techniques for Digital Systems Lab. Verilog HDL. Tajana Simunic Rosing. Source: Eric Crabill, Xilinx

Techniques for Digital Systems Lab. Verilog HDL. Tajana Simunic Rosing. Source: Eric Crabill, Xilinx CSE140L: Components and Design Techniques for Digital Systems Lab Verilog HDL Tajana Simunic Rosing Source: Eric Crabill, Xilinx 1 More complex behavioral model module life (n0, n1, n2, n3, n4, n5, n6,

More information

CSE 591: Advanced Hardware Design and Verification (2012 Spring) LAB #0

CSE 591: Advanced Hardware Design and Verification (2012 Spring) LAB #0 Lab 0: Tutorial on Xilinx Project Navigator & ALDEC s Active-HDL Simulator CSE 591: Advanced Hardware Design and Verification Assigned: 01/05/2011 Due: 01/19/2011 Table of Contents 1 Overview... 2 1.1

More information

Homework deadline extended to next friday

Homework deadline extended to next friday Norm Midterm Grading Finished Stats on course homepage Pickup after this lab lec. Regrade requests within 1wk of posted solution Homework deadline extended to next friday Description Design Conception

More information

271/471 Verilog Tutorial

271/471 Verilog Tutorial 271/471 Verilog Tutorial Prof. Scott Hauck, last revised 9/15/14 Introduction The following tutorial is inted to get you going quickly in circuit design in Verilog. It isn t a comprehensive guide to System

More information

Finite-State Machine (FSM) Design

Finite-State Machine (FSM) Design 1 Finite-State Machine (FSM) Design FSMs, an important category of sequential circuits, are used frequently in designing digital systems. From the daily used electronic machines to the complex digital

More information

Why Should I Learn This Language? VLSI HDL. Verilog-2

Why Should I Learn This Language? VLSI HDL. Verilog-2 Verilog Why Should I Learn This Language? VLSI HDL Verilog-2 Different Levels of Abstraction Algorithmic the function of the system RTL the data flow the control signals the storage element and clock Gate

More information

ENEE245 Digital Circuits and Systems Lab Manual

ENEE245 Digital Circuits and Systems Lab Manual ENEE245 Digital Circuits and Systems Lab Manual Department of Engineering, Physical & Computer Sciences Montgomery College Version 1.1 Copyright Prof. Lan Xiang (Do not distribute without permission) 1

More information

VERILOG: FLIP-FLOPS AND REGISTERS

VERILOG: FLIP-FLOPS AND REGISTERS VERILOG: FLIP-FLOPS AND REGISTERS Semiconductor Memories Single-bit or Memory (Foreground) Individual memory circuits that store a single bit of information and have at least a 1) data input, 2) data output,

More information

Quick Introduction to SystemVerilog: Sequental Logic

Quick Introduction to SystemVerilog: Sequental Logic ! Quick Introduction to SystemVerilog: Sequental Logic Lecture L3 8-545 Advanced Digital Design ECE Department Many elements Don Thomas, 24, used with permission with credit to G. Larson Today Quick synopsis

More information

Verilog Tutorial. Introduction. T. A.: Hsueh-Yi Lin. 2008/3/12 VLSI Digital Signal Processing 2

Verilog Tutorial. Introduction. T. A.: Hsueh-Yi Lin. 2008/3/12 VLSI Digital Signal Processing 2 Verilog Tutorial T. A.: Hsueh-Yi Lin Introduction 2008/3/12 VLSI Digital Signal Processing 2 Verilog: A common language for industry HDL is a common way for hardware design Verilog VHDL Verilog is widely

More information

Chapter 5 Registers & Counters

Chapter 5 Registers & Counters University of Wisconsin - Madison ECE/Comp Sci 352 Digital Systems Fundamentals Kewal K. Saluja and Yu Hen Hu Spring 2002 Chapter 5 Registers & Counters Originals by: Charles R. Kime Modified for course

More information

ECEN 468 Advanced Logic Design

ECEN 468 Advanced Logic Design ECEN 468 Advanced Logic Design Lecture 28: Synthesis of Language Constructs Synthesis of Nets v An explicitly declared net may be eliminated in synthesis v Primary input and output (ports) are always retained

More information

VLSI Design 13. Introduction to Verilog

VLSI Design 13. Introduction to Verilog Last module: Sequential circuit design Design styles This module Synthesis Brief introduction to Verilog Synthesis in the Design Flow Designer Tasks Tools Architect Logic Designer Circuit Designer Define

More information

EE 231 Fall EE 231 Homework 8 Due October 20, 2010

EE 231 Fall EE 231 Homework 8 Due October 20, 2010 EE 231 Homework 8 Due October 20, 20 1. Consider the circuit below. It has three inputs (x and clock), and one output (z). At reset, the circuit starts with the outputs of all flip-flops at 0. x z J Q

More information

Mark Redekopp and Gandhi Puvvada, All rights reserved. EE 357 Unit 15. Single-Cycle CPU Datapath and Control

Mark Redekopp and Gandhi Puvvada, All rights reserved. EE 357 Unit 15. Single-Cycle CPU Datapath and Control EE 37 Unit Single-Cycle CPU path and Control CPU Organization Scope We will build a CPU to implement our subset of the MIPS ISA Memory Reference Instructions: Load Word (LW) Store Word (SW) Arithmetic

More information

Modeling Synchronous Logic Circuits. Debdeep Mukhopadhyay IIT Madras

Modeling Synchronous Logic Circuits. Debdeep Mukhopadhyay IIT Madras Modeling Synchronous Logic Circuits Debdeep Mukhopadhyay IIT Madras Basic Sequential Circuits A combinational circuit produces output solely depending on the current input. But a sequential circuit remembers

More information

Introduction to Nexys 2 board - Detour Signal Lab

Introduction to Nexys 2 board - Detour Signal Lab 1. Synopsis: Introduction to Nexys 2 board - This lab introduces the use of Field Programmable Gate Arrays (FPGA). This lab introduces the Digilent Nexys 2 board and demonstrate FPGA design flow through

More information

CS6710 Tool Suite. Verilog is the Key Tool

CS6710 Tool Suite. Verilog is the Key Tool CS6710 Tool Suite Verilog-XL Behavioral Verilog Your Library Cadence SOC Encounter Synopsys Synthesis Structural Verilog Circuit Layout CSI Verilog-XL AutoRouter Cadence Virtuoso Layout LVS Layout-XL Cadence

More information

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline EECS150 - Digital Design Lecture 4 - Verilog Introduction Feb 3, 2009 John Wawrzynek Spring 2009 EECS150 - Lec05-Verilog Page 1 Outline Background and History of Hardware Description Brief Introduction

More information

ECE 4514 Digital Design II. Spring Lecture 2: Hierarchical Design

ECE 4514 Digital Design II. Spring Lecture 2: Hierarchical Design ECE 4514 Digital Design II Spring 2007 Abstraction in Hardware Design Remember from last lecture that HDLs offer a textual description of a netlist. Through abstraction in the HDL, we can capture more

More information

Verilog for High Performance

Verilog for High Performance Verilog for High Performance Course Description This course provides all necessary theoretical and practical know-how to write synthesizable HDL code through Verilog standard language. The course goes

More information

Verilog Sequential Logic. Verilog for Synthesis Rev C (module 3 and 4)

Verilog Sequential Logic. Verilog for Synthesis Rev C (module 3 and 4) Verilog Sequential Logic Verilog for Synthesis Rev C (module 3 and 4) Jim Duckworth, WPI 1 Sequential Logic Module 3 Latches and Flip-Flops Implemented by using signals in always statements with edge-triggered

More information

Xilinx ASMBL Architecture

Xilinx ASMBL Architecture FPGA Structure Xilinx ASMBL Architecture Design Flow Synthesis: HDL to FPGA primitives Translate: FPGA Primitives to FPGA Slice components Map: Packing of Slice components into Slices, placement of Slices

More information

A Brief Introduction to Verilog Hardware Definition Language (HDL)

A Brief Introduction to Verilog Hardware Definition Language (HDL) www.realdigital.org A Brief Introduction to Verilog Hardware Definition Language (HDL) Forward Verilog is a Hardware Description language (HDL) that is used to define the structure and/or behavior of digital

More information

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited April 2, 2009 John Wawrzynek Spring 2009 EECS150 - Lec20-fsm Page 1 Finite State Machines (FSMs) FSM circuits are a type of sequential

More information

EE178 Lecture Verilog FSM Examples. Eric Crabill SJSU / Xilinx Fall 2007

EE178 Lecture Verilog FSM Examples. Eric Crabill SJSU / Xilinx Fall 2007 EE178 Lecture Verilog FSM Examples Eric Crabill SJSU / Xilinx Fall 2007 In Real-time Object-oriented Modeling, Bran Selic and Garth Gullekson view a state machine as: A set of input events A set of output

More information

This Lecture. Some components (useful for the homework) Verilog HDL (will continue next lecture)

This Lecture. Some components (useful for the homework) Verilog HDL (will continue next lecture) Last Lecture The basic component of a digital circuit is the MOS transistor Transistor have instrinsic resistance and capacitance, so voltage values in the circuit take some time to change ( delay ) There

More information

Synthesis of Combinational and Sequential Circuits with Verilog

Synthesis of Combinational and Sequential Circuits with Verilog Synthesis of Combinational and Sequential Circuits with Verilog What is Verilog? Hardware description language: Are used to describe digital system in text form Used for modeling, simulation, design Two

More information

Topics. Midterm Finish Chapter 7

Topics. Midterm Finish Chapter 7 Lecture 9 Topics Midterm Finish Chapter 7 ROM (review) Memory device in which permanent binary information is stored. Example: 32 x 8 ROM Five input lines (2 5 = 32) 32 outputs, each representing a memory

More information

Workshop on Digital Circuit Design in FPGA

Workshop on Digital Circuit Design in FPGA Organized by: Dept. of EEE Workshop on Digital Circuit Design in FPGA Presented By Mohammed Abdul Kader Assistant Professor, Dept. of EEE, IIUC Email:kader05cuet@gmail.com Website: kader05cuet.wordpress.com

More information

ECE 4514 Digital Design II. Spring Lecture 20: Timing Analysis and Timed Simulation

ECE 4514 Digital Design II. Spring Lecture 20: Timing Analysis and Timed Simulation ECE 4514 Digital Design II Lecture 20: Timing Analysis and Timed Simulation A Tools/Methods Lecture Topics Static and Dynamic Timing Analysis Static Timing Analysis Delay Model Path Delay False Paths Timing

More information

VHDL 2 Combinational Logic Circuits. Reference: Roth/John Text: Chapter 2

VHDL 2 Combinational Logic Circuits. Reference: Roth/John Text: Chapter 2 VHDL 2 Combinational Logic Circuits Reference: Roth/John Text: Chapter 2 Combinational logic -- Behavior can be specified as concurrent signal assignments -- These model concurrent operation of hardware

More information

Testbenches for Sequential Circuits... also, Components

Testbenches for Sequential Circuits... also, Components ! Testbenches for Sequential Circuits... also, Components Lecture L04 18-545 Advanced Digital Design ECE Department Many elements Don Thomas, 2014, used with permission with credit to G. Larson State Transition

More information

L5: Simple Sequential Circuits and Verilog

L5: Simple Sequential Circuits and Verilog L5: Simple Sequential Circuits and Verilog Acknowledgements: Nathan Ickes and Rex Min Lecture notes prepared by Professor Anantha Chandrakasan L5: 6.111 Spring 29 Introductory Digital Systems Laboratory

More information

EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2

EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2 EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2 Professor Sherief Reda http://scaleenginbrownedu Electrical Sciences and Computer Engineering School of Engineering Brown University

More information

Digital Design with SystemVerilog

Digital Design with SystemVerilog Digital Design with SystemVerilog Prof. Stephen A. Edwards Columbia University Spring 25 Synchronous Digital Design Combinational Logic Sequential Logic Summary of Modeling Styles Testbenches Why HDLs?

More information

Asynchronous FIFO Design

Asynchronous FIFO Design Asynchronous FIFO Design 2.1 Introduction: An Asynchronous FIFO Design refers to a FIFO Design where in the data values are written to the FIFO memory from one clock domain and the data values are read

More information

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering Final Examination ECE 241F - Digital Systems Examiners: S. Brown,

More information

Lab 7 (All Sections) Prelab: Introduction to Verilog

Lab 7 (All Sections) Prelab: Introduction to Verilog Lab 7 (All Sections) Prelab: Introduction to Verilog Name: Sign the following statement: On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work 1 Objective The

More information

Using Programmable Logic and the PALCE22V10

Using Programmable Logic and the PALCE22V10 Using Programmable Logic and the PALCE22V10 Programmable logic chips (like the PALCE22V10) provide a convenient solution for glue logic and state machine control required by your design. A single PAL chip

More information

ENGR 3410: Lab #1 MIPS 32-bit Register File

ENGR 3410: Lab #1 MIPS 32-bit Register File ENGR 3410: Lab #1 MIPS 32-bit Register File Due: October 12, 2005, beginning of class 1 Introduction The purpose of this lab is to create the first large component of our MIPS-style microprocessor the

More information

Nikhil Gupta. FPGA Challenge Takneek 2012

Nikhil Gupta. FPGA Challenge Takneek 2012 Nikhil Gupta FPGA Challenge Takneek 2012 RECAP FPGA Field Programmable Gate Array Matrix of logic gates Can be configured in any way by the user Codes for FPGA are executed in parallel Configured using

More information

C A R L E T O N U N I V E R S I T Y. FINAL EXAMINATION April Duration: 3 Hours No. of Students: 108

C A R L E T O N U N I V E R S I T Y. FINAL EXAMINATION April Duration: 3 Hours No. of Students: 108 C A R L E T O N U N I V E R S I T Y FINAL EXAMINATION April 2011 Duration: 3 Hours No. of Students: 108 Department Name & Course Number: ELEC 3500 Digital Electronics Course Instructor(s): Ralph Mason

More information

Introduction to Verilog/System Verilog

Introduction to Verilog/System Verilog NTUEE DCLAB Feb. 27, 2018 Introduction to Verilog/System Verilog Presenter: Yao-Pin Wang 王耀斌 Advisor: Prof. Chia-Hsiang Yang 楊家驤 Dept. of Electrical Engineering, NTU National Taiwan University What is

More information

structure syntax different levels of abstraction

structure syntax different levels of abstraction This and the next lectures are about Verilog HDL, which, together with another language VHDL, are the most popular hardware languages used in industry. Verilog is only a tool; this course is about digital

More information