Solved Assignment 2 for Computer Organization - Fall 2007 | EE 3755, Assignments of Electrical and Electronics Engineering

Material Type: Assignment; Class: COMPUTER ORGANIZATIO; Subject: Electrical Engineering; University: Louisiana State University; Term: Spring 2007;

Typology: Assignments

Pre 2010

Uploaded on 08/30/2009

koofers-user-u15
koofers-user-u15 🇺🇸

10 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EE 3755 Homework 2 Due: March. 23, 2007
##Do NOT MODIFY YOUR SCRIPT FILE AFTER THE DUE DATE.
Estimated time to solve:
Prob.1 5 Minutes. (5 pts)
Prob.2 4 Hours. (40pts)
Prob.3 2 Hours. (30pts)
Prob.4 15 Minutes. (15pts)
Having Script File 5Minutes.(10pts)
Total 6 Hours and 25Minutes.
How to submit?
// No hard copy.
// Name your program file as hw3.v
// Name your script file as hw3.txt
// Leave your program file(hw3.v) and
// your script file(hw3.txt) on the class account.
Finish your program file(hw3.v) first, then do the followings:
Use “script hw3.txt “ command // To take a snap shot of your program. If you don’t know
// script command, look at the handout.
Use “cat hw3.v” command // To display contents of your program.
Use “ncverilog hw3.v” //To run your program.
then stop the script.
Example) SUN>script hw3.txt
SUN>cat hw3.v
SUN>ncverilog hw3.v
SUN> ( stop script by pressing CTRL-D)
#Do all your work on hw3.v file
After carefully read the problem description, write code on the template file(hw3.v).
Most of the code is given on the template file.
You have to add about 30 lines of code on the module serial_taggeddata_alu (result,v,ck);
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Solved Assignment 2 for Computer Organization - Fall 2007 | EE 3755 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EE 3755 Homework 2 Due: March. 23, 2007

##Do NOT MODIFY YOUR SCRIPT FILE AFTER THE DUE DATE.

Estimated time to solve:

Prob. 1 5 Minutes. (5 pts)

Prob. 2 4 Hours. (40pts)

Prob.3 2 Hours. (30pts)

Prob. 4 15 Minutes. (15pts)

Having Script File 5Minutes.(10pts)

Total 6 Hours and 25Minutes.

How to submit?

// No hard copy.

// Name your program file as hw 3 .v

// Name your script file as hw 3 .txt

// Leave your program file(hw 3 .v) and

// your script file(hw 3 .txt) on the class account.

Finish your program file(hw3.v) first, then do the followings:

Use “script hw3.txt “ command // To take a snap shot of your program. If you don’t know

// script command, look at the handout.

Use “cat hw3.v” command // To display contents of your program.

Use “ncverilog hw3.v” //To run your program.

then stop the script.

Example) SUN>script hw3.txt

SUN>cat hw3.v

SUN>ncverilog hw3.v

SUN> ( stop script by pressing CTRL-D)

#Do all your work on hw3.v file

After carefully read the problem description, write code on the template file(hw3.v).

Most of the code is given on the template file.

You have to add about 30 lines of code on the module serial_taggeddata_alu (result,v,ck);

,add about 10 about 30 lines of code on the module serial_pattern_checker (v,ck ).

Description for the Problem 2##

You are required to build a serial arithmetic unit. module serial_taggeddata_alu(result,v,ck); The unit will receive one bit at every clock cycle. After receiving 8bits, you may convert the 8 bit-data into a number or and an operator. The rule of conversion is these followings. When the MSB and following bit of the data are 00, then interpret following 6 bits data as an operator. When the MSB and following bit of the data are 01, then interpret following 6 bits data as an positive integer number. When the MSB and following bit of the data are 10, then interpret following 6 bits data as an negative integer number. You only have to implement “+” operator, “x” operator, and “ =” operator. Assume code for “+” “00 000001”, (addition) code for “x” “00 000010”, (multiplication) code for “=” “00 000011”. You will receive a series of a number and an operator or “=”. After you receive “=” data, you will display the output and stop. For example: Think about this equation:

  1. (7+(-4)) x 5 =
  2. You may assume receiving “ 7 ”, “+”, “-4”, “x”, “ 5 ”,and “=”. But actually you will receive their coded values which are “ 01000111 ” (which is 01+000111), // 7 “ 00000001 ” (which is 00+000001), // + “ 10000100 ” (which is 10+000100), // (-4) “ 00000010 ” (which is 00+000010), // x “ 01000101 ” (which is 01+000101), // 5

//Template //Copy this template and name it "hw 3 .v". // Problem 0: // Write down your name and your account here // Your Name : ####### // Your Account: ####### // //Problem 1 :( 5 pts) //Look at the memory module below and answer //The memory unit contains data and operators. // What will be the equation? //Answer : //(hint: something like 1+2+3 =) // //Data Memory Module //Look at it and give an answer for the problem 1. module memory(); reg [7:0] mem [7:0]; initial begin mem[0] = 7+64; //tagged data for 7 mem[1] = 1; //operator code for + mem[2] = 4+128; //tagged data for - mem[3] = 2; //operator code for x mem[4] = 5+64; //tagged data for 5 mem[5] = 3; //operator code for = mem[6] = 3; mem[7] = 3; end

endmodule //You don't have to change anything from this part. //This module memory_read_s will read 1 bit data from memory. module memory_read_s(v,ck); input ck; output v; reg [7:0] local_v, index; reg [3:0] cnt; memory m(); reg v; initial index = 0; initial cnt = 0; always @(ck) begin local_v = m.mem[index]; v = local_v[cnt]; cnt = cnt+1; if(cnt == 8) begin cnt = 0; index = index +1; end end endmodule // ////////////////////////////////////////////////////// //////You don’t have to read code below. This is a part of the testbench. ///// Another data memory for the testbench ///// you don't have to know module memory2(); reg [7:0] mem [7:0]; initial begin mem[0] = 7+64; //tagged data for 7 mem[1] = 1; //operator code for + mem[2] = 4+128; //tagged data for -

reg[7:0] local_data1,local_data2,result,temp_result,temp_local_data; // you will save the incoming bit stream into the registers. // or you can declare more regs and save the value on them. reg[3:0] cnt; reg[2:0] operator; //add : 1 //multiply : 2 parameter op_add = 1; parameter op_mul = 2; initial temp_result = 0; initial operator = 3; // initial cnt = 0; always @(ck)

begin /// Write down your code here /// It should contain this code: $display("result output = %d\n",result); /// And this : #1 $stop; //Why #1 before $stop? //Answer: you give time to the simulator to do //something before it stops. /// The code length will be less than 40 lines. /// My code length is 33 lines. /// There will be no penalty for a little bit longer code /// as long as your program produces right answer end endmodule ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////Do not modify this test_all module//////////////////////////////////////////////////// module test_all(); integer i,j; reg ck; wire [3:0] v1;

wire vs,vs2; wire same; wire [7:0] result2,result; initial ck = 0; initial begin for(i = 1; i<= 80; i = i+ 1) begin #10; ck = ~ck; end end memory_read_s m_r_s(vs,ck); serial_taggeddata_alu s_a_a(result,vs,ck); memory_read_s2 m_r_s2(vs2,ck); serial_taggeddata_alu s_a_a_2(result2,vs2,ck); initial $monitor($time, " result = %d,result2 = %d",result,result2); endmodule //Problem 3 Complete the module so it can perform the required functionality.(30pts) module memory11(); reg [7:0] mem [7:0]; initial begin mem[0] = 15; mem[1] = 1; mem[2] = 8'b11110000; // mem[3] = 2; mem[4] = 8'b11111111; mem[5] = 8'b01111110; mem[6] = 3; mem[7] = 3; end endmodule

always @(ck) begin /// Write down your code here /// /// The code length will be less than 10 lines. /// use this command for displaying time: $display($time, "got pattern 1111\n"); /// There will be no penalty for a little bit longer code /// as long as your program produces right answer end endmodule ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////Do not modify this test_all module//////////////////////////////////////////////////// module test_all2(); integer i,j; reg ck; wire [3:0] v1; wire vs,vs2;

initial ck = 0; initial begin // #1000; for(i = 1; i<= 80; i = i+ 1) begin #1; ck = ~ck; end end memory_read_s1 m_r_s(vs,ck); serial_pattern_checker s_p_c(vs,ck); endmodule // Problem 4 : Convert the following numbers. (15pts) // 4 .1) Decimal 11 to 8-bit Binary: (2pts) // Write your answer here: // // 4 .2) Decimal - 11 to 8-bit Binary ( 2 pts) // Write your answer here: // /// 4 .3) Decimal 11 .875 to Binary (as many bits as needed) ( 3 pts) // Write your answer here: // // 4 .4) Decimal - 11 .875 to IEEE 754 Single Precision (8pts) // (Show in hexadecimal): // Write your answer here: // //