Assignment #1 – Combinational logic
Before doing the assignment questions, please get expertise with GVIM.
- Half Adder
- Ports
- Input: a, b (8 bit input)
- Output: s, co
- Implement half adder logic using assign
- Implement testbench to check the half adder behaviour
- Testbench file name: tb_ha.v
- Use :spl to create a new file tb_ha.v
- Include ha.v in tb_ha.v
- Declare all design inputs as reg
- Copy the same line as in design file, use ‘cw’ command to change input to reg.
- Use yy, y1 commands to copy lines from design file and use ‘p’ to paste in tb file.
- To switch between each file, use ‘Ctrl+w’, followed by up or down arrow
- Create half adder module instance
- Use ctlr+w and arrow to move cursor to ha.v file
- Go to design module definition line(line number 1)
- Use up or down arrow to move the cursor
- yy
- ctrl+w, arrow move to tb_ha.v
- ‘p’ to paste that line in tb_ha.v
- Go to the line below which we want to paste module definition
- Remove module
- Keep cursor on m of the module
- dw
- Drive a, b with random value
- Use $monitor to monitor a, b, s and co
- Implement half adder logic in always block
- Always @(a or b)
- Anytime a or b changes, half adder should work
- Implement half adder using logic gates
- Truth table, K-maps, Boolean expression, circuit, coding
- For a 8 bit input vectors, it’s quite complex
- DO it only using 1 bit half adder and tb also for 1 bit ha.
- Full adder
- Use half adder coded above to implement full adder
- Search how to implement full adder using half adder in google.
- Use ha_gate.v, 1 bit Half adder to do this.
- If this works, see how 8 bit FA can also be implemented.
- Write test bench to check design behaviour
- Implement 4×1 Mux using behavioural code
- Mux behaviour implemented using if else statements
- Same can be done using case statement also.
- Implement 4×1 Mux using continuous assignments, i.e. Data flow model.
- Assign Y = S1 ? (S0 ? i3 : i2) : (S0 ? i1 : i0);
- Do not code assign inside always
- 4×1 Multiplexor using Kmaps
- Truth table for Mux output
- Ideally, we need 64 entry truth table, but with proper understanding, we can do it in 4 entries.
- 0 0 i0 => this entry is y = ~s0~s1i0
- Like above total 4 entries will be there.
- All this minterms are ORed to get the final expression
- K-Maps
- Boolean expression
- Show the final expression.
- Implement Boolean expression using Verilog logic gates
- Module ports?
- How many outputs?
- Outputs declared as reg or wire.
- Boolean expression: y= ~s0~s1i0 + s0~s1i1 + ~s0s1i2 + s0s1i3
- How to implement AND gate in Verilog
- Write a testbench
- Use $random with input variable concatenation to generate random inputs
- What does $random do?
- Generates a 32 bit random number
- Repeat this for 20 times
- Why we need do give #1 delay inside repeat?
- Many students declaring n1, n2, n3, n4 in testbench also.
- Only Design inputs and outputs should be copied to testbench file, not the design internal signals.
- $monitor to display and check the outputs
- Write $monitor with $time printed
- Check how many times display happens
- Why some timesteps are not displayed.
- Understand how $display differs from $monitor
- Also add signals to the waveform and check the behaviour.
- Implement 8×1 Mux using 4×1 Mux?
- Come up with 8×1 Mux diagram using 4×1 mux only (don’t use 2×1 mux)
- Instantiate 4x1mux to create 8×1 mux design Verilog code.
- This concept is called as Hierarchical modelling.
- Using smaller modules, creating bigger modules.
- Module mux8x1
- There won’t be any logic coding. It is all about instantiating 4×1 mux 3 times, connecting its ports.
- How to instantiate first 4×1 Mux in the design
- Mux4x1 u1(.i0(i4), .i1(i5), .i2(i6), .i3(i7), .s0(s0), .s1(s1), .y(n1));
- Mux4x1 u1(i4, i5, i6, i7, s0, s1, n1);
- Ports order mux4x1 should be in same order as above
- Multiplexer (8 to 1 mux)
- Write testbench to check design behaviour
- Encoder, decoder and priority encoder
- Write testbench to check design behaviour
- Encoder, decoder and priority encoder implementation using multiplexer
- Implement above designs using multiplexer
- Write testbench to check design behaviour
- Implementing various gates using multiplexer
- Implement AND, OR, NAND, NOR, XOR, XNOR using multiplexer
- 4×1 Multiplexor using Boolean expression
- Write the Verilog code using above expression
- Develop testbench and run the simulation.
- Implement 1-bit half subtractor
- Using above implement 1 bit full subtractor
- Using above implement 3 bit full subtractor
- Implement 8×1 mux using
- 2 – 4×1 Mux
- 1 – 2×1 Mux
- Implement 1 bit comparator
- Behavioral
- Data flow
- Structural
- Implement 2 bit comparator
- Behavioral
- Data flow
- Structural
- Using 1 bit comparator
-
- Implement multi bit comparator
- Behavioral
- Data flow
- Structural
-
THEORY QUESTIONS
- How hardware differs from software?
- How Verilog implements
- Concept of time
- Concept of structure
- Concept of concurrent process
- Concept of states
- How Verilog language differs from C language?
- Why Verilog is called as Hardware description language, not a programming language?
- What does EDA stand for?
- How EDA tools make the whole VLSI design process easier?