






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: COMPUTER ORGANIZATIO; Subject: Electrical Engineering; University: Louisiana State University; Term: Spring 2007;
Typology: Assignments
1 / 11
This page cannot be seen from the preview
Don't miss anything!







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 ).
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:
//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: // //