Due date: See Canvas
mkdir ~/cs355/hw2 cp /home/cs355001/Handouts/hw2/* ~/cs355/hw2 |
You will copy these files:
basic.h - the commonly used circuit components in the CS355 assignments Full_Adder aa c_in a b | c_out sum; You can use the Full_Adder components in assignment hw2 help-hw2 - the main simulation program file It creates switches and probes to help you test the circuit (macro) that you must make in this assignment hw2.h - This file contains the circuit that you must make for assignment 2 |
Write a ``Mult4'' component (i.e., a macro) that defines a 4-bit multiply circuit.
|
This component ``Mult4'' must be store in the file hw2.h so that it can be included by the help-hw2 circuit file provided for this assignment.
I provided the header of the ``Mult4'' component in hw2.h already:
/* Skeleton program file for hw2 */ Define Mult4 x3 x2 x1 x0 y3 y2 y1 y0 | m7 m6 m5 m4 m3 m2 m1 m0; /* ------------------------------------------------------------ Write the multiply circuit here The 1st binary number = (x3 x2 x1 x0) - x0 is the least significant bit The 2nd binary number = (y3 y2 y1 y0) - y0 is the least significant bit The output (product) = (m7 m6 m5 m4 m3 m2 m1 m0) - m0 is the least significant bit ------------------------------------------------------------ */ Endef; |
where:
|
Defining a macro in EDiSim:
|
|
|
The Mult4 circuit has:
|
Schematically:
1 0 1 1 multiplicant x 1 0 0 1 multiplier ----------------------- 1 0 1 1 <--- 1 + 0 0 0 0 <--- 0 ----------------------- 0 1 0 1 1 + 0 0 0 0 <--- 0 ----------------------- 0 0 1 0 1 1 + 1 0 1 1 <--- 1 ----------------------- 1 1 0 0 0 1 1Notice that:
|
The circuit test environment program code will perform the following:
|
|
|
|
Repeat: to do this assignment, all you have to do is:
|
In this assignment, you will need to use some full adders to make the 4-bits multiply circuit
I have already defined the Full_Adder component inside basic.h:
/* Full adder. Syntax: Full_Adder a b c_in | c_out s; Effect: Adds binary numbers a + b with carry. */ Define Full_Adder CarryIn a b | CarryOut Sum; Xor aa a b x; Xor ab x CarryIn Sum; And bb a b y; And cb CarryIn x z; Or cc y z CarryOut; Endef; |
(Take a look inside the basic.h file in your assignment directory.
You can use the Full_Adder component that is defined in the help file basic.h in this assignment.
Full_Adder aa carryIn inp1 inp0 | carryOut sum ; |
An example of how to use the Full_Adder component can also be found in the demo program file 4-bit-adder.m which was demonstrated in class. This demo file can be viewed with:
nano /home/cs355001/demo/circuits/4-bit-adder.m |
/* Skeleton program file for hw2 */ Define Mult4 x3 x2 x1 x0 y3 y2 y1 y0 | m7 m6 m5 m4 m3 m2 m1 m0; /* ------------------------------------------------------------ Write the multiply circuit here ------------------------------------------------------------ */ Endef; |
Use this skeleton program file and write the Mult4 macro that will multiply:
|
and outputs the product as a 8 bit number m7 m6 m5 m4 m3 m2 m1 m0
The least significant bit of the binary number has index 0 and the most significant bit of the binary number has index 3 or 7.
cs355sim help-hw2 or: (If you get a cs355sim: not found error message) /home/cs355001/bin/cs355sim help-hw2 |
Ofcourse, this command will only work after you have finished the Mult4 component in the file hw2.h
/home/cs355001/Solutions/hw2-sol |
cd ~/cs355/hw2 (go to the correct directory) /home/cs355001/turnin hw2.h hw2 (turn in hw2.h) |
(A 4th extension request will be automatically denied --- personal emergencies and illiness with documentation will receive a "free" extension)
/home/cs355001/req-ext hw2 (must be executed in a SSH window) |
The page is accessible through the following hyperlink: click here
I will keep updating this page when students report their compile and run time errors to me.
Check this page first to see if your error is found there !
Submissions based on other students solutions in prior offerings of the course specifically violate these guidelines, as do submissions prepared with the help of an outside "tutor".
You should take precautions to protect the confidentiality of your work: preserve the secrecy of your password, do not make files or directories sharable, pick up your printouts promptly and dispose of printouts where they will not tempt other students. All work should be done either in the class directory of your ITD account (preferred) or in your "priv" directory (only if you do not have a class directory).
All submissions should include a comment statement near the top of the program of the form:
/* THIS CODE IS MY OWN WORK, IT WAS WRITTEN WITHOUT CONSULTING A TUTOR OR CODE WRITTEN BY OTHER STUDENTS - your name */
Cases of apparent plagiarism or collusion will be referred to the Honor Council.