代写EECS112L Organization of Digital Computers Lab Fall 2024 Lab 1代写留学生R语言

Organization of Digital Computers Lab

EECS112L

Fall 2024

Lab 1 (100 Points)

In this lab, you are given an arithmetic logic unit (ALU) design, which you are to test. The design has some bugs in it. You will design a testbench to test the functions of the ALU to find the bugs. You will also revise the sequential logic (D flip-flops) and create testbench for it.

1 ALU Overview

An ALU performs basic arithmetic and logic operations. Examples of arithmetic operations are addition, subtraction, multiplication, and division. Examples of logic operations are comparisons of values ,such as NOT, AND, and OR. This ALU has 2 4-bit inputs A and B for operands, a 4-bit input ALU_Sel for selecting the operation, a 4-bit output ALU_Out, and a 1-bit output CarryOut. The datapath is just 4-bits wide to allow for easy coverage testing of the different operations. The operations of the ALU are specified in the table below.

ALU_Sel          ALU Operation

0000              ALU ut = A + B

0001              ALU ut = A - B

0010              ALU ut = A * B

0011              ALU ut = A / B

0100              ALU ut = A << 1

0101              ALU ut = A >> 1

0110              ALU ut = A rotated left by 1

0111              ALU ut = A rotated right by 1

1000              ALU ut = A and B

1001              ALU ut = A or B

1010              ALU ut = A xor B

1011              ALU ut = A nor B

1100              ALU ut = A nand B

1101              ALU ut = A xnor B

1110              ALU ut = 1 if A>B else 0

1111              ALU ut = 1 if A=B else 0

Note: Check canvas for some review slides on Verilog operators.

Below you see the Verilog code for the ALU. Create a new Vivado project and copy this code to a file named alu.v.

Code 1: 4-bit ALU.

module alu ( input [3:0] A,B, // ALU 4- bit Inputs input [3:0] ALU_Sel ,// ALU Selection output [3:0] ALU_Out , // ALU 4- bit Output output CarryOut // Carry Out Flag ); reg [7:0] ALU_Result ; wire [4:0] tmp ; assign ALU_Out = ALU_Result ; // ALU out assign tmp = {1’b0 ,A} + {1’b0 ,B}; assign CarryOut = tmp [4]; // Carryout flag always @ (*) begin case ( ALU_Sel ) 4’ b0000 : // Addition ALU_Result = A + B; 4’ b0001 : // Subtraction ALU_Result = A - B; 4’ b0010 : // Multiplication ALU_Result = A ** B; 4’ b0011 : // Division ALU_Result = A/B; 4’ b0100 : // Logical shift left ALU_Result = A <=1; 4’ b0101 : // Logical shift right ALU_Result = A > >1; 4’ b0110 : // Rotate left ALU_Result = {A [2:0] , A [3]}; 4’ b0111 : // Rotate right ALU_Result = {A[3] ,A [3:1]}; 4’ b1000 : // Logical and ALU_Result = A && B; 4’ b1001 : // Logical or ALU_Result = A || B; 4’ b1010 : // Bitwise xor ALU_Result = A ˆ B; 4’ b1011 : // Logical nor ALU_Result = ∼(A || B); 4’ b1100 : // Logical nand ALU_Result = ∼(A && B); 4’ b1101 : // Bitwise xnor ALU_Result = ∼ (A ˆ B); 4’ b1110 : // Greater comparison ALU_Result = (A>B) ? 4’b0 : 4’b1; 4’ b1111 : // Equal comparison ALU_Result = (A==B) ? 4’b1 : 4’b0; default : ALU_Result = A + B; endcase end endmodule

2 Verification of Combinational Logic - ALU

1. Create the testbench, called tb alu.v and add it to your Vivado project. You can use the testbench from lab 0 as a starting point.

2. Test the Addition (0000) operation.

(a) (15 points) Modify the testbench to provide stimulus that sets ALU sel to the appropriate op code and sweeps through all possible combinations of inputs from A=0000, B=0000 to A=1111, B=1111. Include the simulation waveform. in your report. (Note: only report several combinations of A and B. Explain the different parts of these waveform. in details such as, the inputs, the outputs, and the expected result.)

(b) (15 points) Is the operation implemented correctly? If not, indicate on the waveform. where at least one of outputs was incorrect. Identify which line in alu.v contains the mistake, and propose a correction to this line in you report. Create a new file called alu fixed.v with the mistakes being corrected. The ports declaration should be the same as alu.v and the name of the new module should be alu fixed. Any changes in the port declaration will cause your module to fail during grading and you will lose all the points.

3. (15 points) Repeat Step 2(a-b) for the following operations: multiplication, logical shift left, rotate right, logical AND, and greater comparison.

Note: If the operation is not implemented correctly, you need to report the simulation waveform. for at least one of the parts for which the output was incorrect. If the operation is implemented correctly, you need to report the simulation waveform. for only 2-3 parts of the waveform. and show why the outputs are correct.

Note: Remember the fixed version of your ALU has to fix all the bugs. For example, the carryout is not implemented correctly in the given ALU. You need to think how to fix it to make sure that your operations are running correctly.

Note: Your module name of the the fixed version of the alu has to be called (alu fixed) with the same ports names as the provide module above. The file name has to be called (alu fixed.v)

3 (40 points) Verification of Sequential Logic - D flip-flop

In lecture 1, we covered D flip-flop as an example for sequential logic circuits. Use the code from the lecture as a start and implement the following two versions of the D flip-flop:

• D flip-flop with synchronous set/reset. (filename: dff_SR.v)

• D flip-flop with asynchronous preset/clear. (filename: dff_PC.v)

Design two testbenches to test for the correct operation of the two version of D flip-flop. Show the waveform. from your testbench. Explain on your waveform. how your flip-flop works correctly as expected. File names should be (filename: tb_dff_SR.v), and(filename: tb_dff_PC.v).

The module declarations in your code for this question must be as follows:

• D flip-flop with synchronous set/reset: module dff SR (clk, d, set, reset, q);

• D flip-flop with asynchronous preset/clear: module dff PC (clk, d, preset, clear, q);

Note: If the simulation of the new testbenches does not show up, you should do the following:

• File > Close Simulation

• Right-Click on the testbench you want to simulate > Set as Top

• Run the simulation again.

(10 points design + 10 points tb and waveform. for each FF)

4 (15 points) Midterm Question Winter 2022

Below is a Verilog code for synchronous reset (active low), synchronous load for an 8-bit counter with carryout.

Convert it into asynchronous reset (active low), synchronous load 8-bit counter with carryout.

(Full points will be based on the correct design and syntax.)

Code 2: 4-bit ALU.

module c tr 8 ( output reg [ 7 : 0 ] counter , output reg carryout , input [ 7 : 0 ] data , input load , clk , r e s e t ); always @( posedge c l k ) begin i f (! r e s e t ) { carryout , count e r } <= 9 ’ b0 ; e ls e i f ( load ) { carryout , count e r } <= data ; e ls e { carryout , count e r } <= count e r + 1 ’ b1 ; end endmodule

The solution for this question is a written solution and has to be added to the submitted report. No need for Verilog design file for this one (Check the assignment deliverables).

5 Assignment Deliverables

Your submission should include the following:

• Testbench for the provided alu.v, the new proposed ALU design (tb alu.v, alu fixed.v).

• Design and testbench files for the two versions of the D flip-flops (dff SR.v dff PC.v, tb_dff_SR.v, and tb_dff_PC.v).

• A report in pdf format. Follow the rules in the “sample report” under “additional resources” in the Canvas. The report file name should be “firstname_last_name_Lab1.pdf”

Note1: Compress all files (7 files : 6 .v files + report) into zip and upload to canvas before deadline.

Note2: Use the code samples that are given in the lab description and in the lectures. The module part of your ALU should exactly look like the code sample otherwise you lose the lab points (module name, module declaration, ports names, and ports declaration) - If you are not sure, please ask your TA during the discussion if your submission files follow the submission guidelines.

Note3: The name of the files should be exactly as mentioned above.

Note4: Work individually and submit before the deadline.

If you are using Vivado on the server, you need to copy your file from the server to some local drive on your computer.

You can type this command (change the file path) in the terminal:

scp username@hostname:/path/to/remote/file /path/to/local/file

6 Extra Exercise - No submission needed for this part

In order to review the digital design basics and syntax, it is highly recommended that you try to implement the following Digital Blocks. It will help you with the future labs and with the Verilog syntax.

• Multiplexer

• Decoder

• Encoder

• Comparator

• Half Adder

• Full Adder

• Adder/Subtractor

• Sign extender

• Shift Register

• Complementer

Revise single cycle processor (data path + control path) from EECS112.

Appendix

set/reset in D flip-flop

when set is “0” and reset is “0”, then output Q will follow the input D.

when set is “1” and reset is “0”, then output Q is 1.

when set is “0” and reset is “1”, then output Q is 0.

when set is “1” and reset is “1”, it is an illegal combination of the inputs. (We are just going to avoid this combination of inputs in our test.)

preset/clear in D flip-flop

when preset is “0” and clear is “0”, then output Q will follow the input D.

when preset is “1” and clear is “0”, then output Q is 1.

when preset is “0” and clear is “1”, then output Q is 0.

when preset is “1” and clear is “1”, it is an illegal combination of the inputs. (We are just going to avoid this combination of inputs in our grading testbench).

Carryout in ALU

Operation                              CarryOut

A + B                                    the 5th bit (carry out)

A − B                                    the barrow bit

A ∗ B                                     the 5th bit of the result

A / B                                     the 5th bit of the result (result for divide by 0 are undefined or X)

A << 1                                   the shifted bit

A >> 1                                       -

rotate left                                   -

rotate right                                  -

and                                             -

or                                                -

xor                                               -

nor                                              -

nand                                             -

xnor                                              -

greater than                                   -

equal                                             -

You can find more about these topics in any logic design or computer architecture book (materials from EECS31 or EECS112 courses)





热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图