Question

A specific type of bit-level manipulation consists in setting or clearing one single bit in a...

A specific type of bit-level manipulation consists in setting or clearing one single bit in a multi-bit value, given its index and its new value. This operation can be implemented in hardware by a BitSet circuit with the following interface:

  • Input x is a 4-bit value representing the original value.
  • Output y is a 4-bit value representing the modified value, after the bit-set operation.
  • Input index is a 2-bit value, ranging from 0 to 3, indicating the index of the bit to modify.
  • Input value is a 1-bit value set to 0 or 1, indicating the value that bit index should take in output y. Every other bit in y should match the corresponding bit in x.

a) Show a hierarchical design of a 4-bit BitSet circuit using any kind of combinational logic blocks (MUX, Decoder, etc). For each reused logic block, specify its exact name and size, and label its complete interface. Label the interface of the BitSet circuit, too, matching the inputs and output listed above.

b) Write a Verilog module for the BitSet circuit using a structural model. If your circuit uses any auxiliary combinational block (multiplexer, decoder, …) you can use any other implementation model for its Verilog module (dataflow or behavioral).

c) Write a Verilog test-bench for your circuit, exploring at least four different combinations
for the inputs.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

the design of the circuit is shown below:

the decoder selects the bit at which the change needs to be made and the mux routes the changed output to the selected bit and rest remain unchanged

the Verilog HDL module for the following is shown below:

// Code your design here
module design1(x,y,index,value);
input [3:0] x;// 4 bit wide inputs x
input [1:0] index; // 2 bit wide input index
input value;// 1bit wide input value
output reg [3:0] y;// output 4 bit wide
wire [3:0] x_sel;
decoder d1(index,x_sel);
mux m3({value,x[3]},x_sel[3],y[3]);
mux m2({value,x[2]},x_sel[2],y[2]);
mux m1({value,x[1]},x_sel[1],y[1]);
mux m0({value,x[0]},x_sel[0],y[0]);
endmodule

module decoder(index,x_sel);
input [1:0] index;
output reg [3:0] x_sel;
  
always@(*)
begin
case(index)
0: x_sel=1;//0001
1:x_sel=2;//0010
2:x_sel=4;//0100
3: x_sel=8;//1000
endcase
end
endmodule
module mux(i,sel,y);
input [1:0] i;
input sel;
output y;
  
assign y=sel?i[1]:i[0];
endmodule

testbench:

// Code your testbench here
// or browse Examples
module test();
reg [3:0] x;
reg [1:0] index;
reg value;
wire [3:0] y;
design1 d1(.*);// design instanciation
initial
begin// sending inputs
x=4'b1010;value=1;index=0;
#2 index=0;
#2 index=1;
#2 index=2;
#2 index=3;
#2 x=4'b1101;
#2index=0;
#2 index=1;
#2 index=2;
end
initial
begin
$dumpfile("dump.vcd");
$dumpvars(1);
end
endmodule

waveform:

Add a comment
Know the answer?
Add Answer to:
A specific type of bit-level manipulation consists in setting or clearing one single bit in a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a combinational circuit that accepts a 2-bit number and generates a 4-bit binary number output...

    Design a combinational circuit that accepts a 2-bit number and generates a 4-bit binary number output equal to the square of the input number. Use Decoder and any other external gates as necessary to implement your design. Draw the logic diagram and clearly label all input and output lines.

  • Building and testing basic combinational circuits using Verilog HDL Description: Build and test t...

    Building and testing basic combinational circuits using Verilog HDL Description: Build and test the following circuits using gate-level modeling in Verilog HDL. 1. 3-input majority function. 2. Conditional inverter (see the table below: x - control input, y - data input). Do NOT use XOR gates for the implementation.    x y Output 0   y 1   y' 3. Two-input multiplexer (see the table below: x,y - data inputs, z - control input).     z Output 0 x 1 y 4. 1-bit half...

  • Building and testing basic combinational circuits using Verilog HDL Description: Build and test the following circuits using gate-level modeling in Verilog HDL 1.3-input majority function 2.Condition...

    Building and testing basic combinational circuits using Verilog HDL Description: Build and test the following circuits using gate-level modeling in Verilog HDL 1.3-input majority function 2.Conditional inverter (see the table below: x - control input, y -data input). Do NOT use XOR gates for the implementation. Output 3. Two-input multiplexer (see the table below: x.y -data inputs, z- control input) Output 4. 1-bit half adder. 5. 1-bit full adder by cascading two half adders 6.1-bit full adder directly (as in...

  • Design a combinational logic circuit which has one output Z and a 4-bit input ABCD representing...

    Design a combinational logic circuit which has one output Z and a 4-bit input ABCD representing a binary number. Z should be 1 iff the input is at least 5, but is no greater than 11. Use one OR gate (three inputs) and three AND gates (with no more than three inputs each). Using K-map, find min SOP and min POS form for the outputs W, X

  • Timescale is set to 100 ps / 1ps and the 1-bit signal of both inputs A...

    Timescale is set to 100 ps / 1ps and the 1-bit signal of both inputs A and B is (0,0) -> (0,1) -> (1,0) -> (1,1 ) To simulate the output waveform of each logic when input to the AND, OR, NAND, NOR, and XOR logic with two inputs. Please submit the following for your design logic: (1) Verilog code (basic.v). (2) Testbench code (tb1.v) (3) Execute (1) in ModelSim to output the waveform ◼ Define a module with the...

  • number 4 and 5 please! PROBLEM STATEMENT A logic circuit is needed to add multi-bit binary...

    number 4 and 5 please! PROBLEM STATEMENT A logic circuit is needed to add multi-bit binary numbers. A 2-level circuit that would add two four-bit numbers would have 9 inputs and five outputs. Although a 2-level SOP or POS circuit theoretically would be very fast, it has numerous drawbacks that make it impractical. The design would be very complex in terms of the number of logic gates. The number of inputs for each gate would challenge target technologies. Testing would...

  • 1. (15 pts) Simplify the following Boolean functions using K-maps: a. F(x,y,z) = (1,4,5,6,7) b. F(x,...

    1. (15 pts) Simplify the following Boolean functions using K-maps: a. F(x,y,z) = (1,4,5,6,7) b. F(x, y, z) = (xy + xyz + xyz c. F(A,B,C,D) = 20,2,4,5,6,7,8,10,13,15) d. F(A,B,C,D) = A'B'C'D' + AB'C + B'CD' + ABCD' + BC'D e. F(A,B,C,D,E) = (0,1,4,5,16,17,21,25,29) 2. (12 pts) Consider the combinational logic circuit below and answer the following: a. Derive the Boolean expressions for Fi and F2 as functions of A, B, C, and D. b. List the complete truth table...

  • Objective: In this lab, we will learn how we can design sequential circuits using behavioral mode...

    Just need the code for the random counter,Thanks Objective: In this lab, we will learn how we can design sequential circuits using behavioral modelling, and implementing the design in FPGA. Problem: Design a random counter with the following counting sequence: Counting Sequence: 04 2 9 168573 Design Description: The counter has one clock (Clock), one reset (Reset), and one move left or right control signal (L/R) as input. The counter also has one 4bit output O and one 2bit output...

  • show its derivation to get the full mark. 2. (10 marks) 0 3 Figure 2: Mapping...

    show its derivation to get the full mark. 2. (10 marks) 0 3 Figure 2: Mapping from input bits to different LED segments on a SSD Design a structural System Verilog module for a 7 segment display decoder that has a four bit input C, and produces a seven bit outpt Y which can be used to display the character associated with the hexadecimal value of C on a 7-segment display. The seven segments in the display are identified with...

  • ECE 1552- Summer 2019 Homework 2: Solve all questions. HW is to be turned in as a PDF or word document on canvas. Show...

    ECE 1552- Summer 2019 Homework 2: Solve all questions. HW is to be turned in as a PDF or word document on canvas. Show all working. Answers provided should be typed or written CLEARLY 1: Find a function to detect an error in the representation of a decimal digit in BCD. In other words, write an equation with value 1 when the inputs are any one of the six unused bit combinations in the BCD code, and value 0 otherwise...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT