Based Logic Design - CAD Based Logic Design - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of CAD Based Logic Design which includes Divide and Conquer, Stitching Up, Computation, Design Problem, Leaf Subproblem, Carry-Lookahead Adder, Intricate Techniques, Fast Tree Designs, Associative Operations etc. Key important points are: Based Logic Design, Test Stimuli, Testbenches, File Definition, File Declaration, File Class, File Object, File Reading, Vhdl Implicitly, File Writing, Problem Description, Files in Subprograms

Typology: Slides

2012/2013

Uploaded on 03/21/2013

dheeraj
dheeraj 🇮🇳

5

(4)

101 documents

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 368
CAD-Based Logic Design
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Based Logic Design - CAD Based Logic Design - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

ECE 368

CAD-Based Logic Design

Files

• In all the testbenches we created so far, the test

stimuli were coded inside each testbench.

• Hence, if we need to change the test stimuli we

need to modify the model or create a new model.

• Input and output files can be used to get around

this problem.

File reading

• Given a file definition, VHDL implicitly provides the

following subprograms:

type file_type is file of element_type;

procedure read ( file f: file_type; value : out element_type; length : out natural); function endfile ( file f: file_type ) return boolean ;

If the length of the element is greater than the length

of the actual data on the file, it is placed left justified

in the element.

Example

p1: process is

type bit_vector_file is file of bit_vectors; file vectors: bit_vector_file open read_mode is “vec.dat”; variable next_vector : bit_vector (63 downto 0); variable actual_len: natural;

begin

while not endfile(vectors) loop read (vectors,next_vector,actual_len); if actual_len > next_vector’length then report “vector too long”; else for bit_index in 1 to actual_len loop …. end loop; end if; end loop; wait;

end process; Docsity.com

Problem Description

• Write a process description that writes the

data of integer type from an input signal to

a file.

• Assume that the input signal “s1” is an “in”

port of the top level entity.

• Assume the file name to be “out.dat”.

Example

P1: process (s1) is

type integer_file is file of integer;

file out_file: integer_file open write_mode is

“out.dat”;

begin

write (out_file,s1);

end ;

Example

function read_array (file_name: string; len: natural) return integer_vector is type integer_file is file of integer; file data_file: integer_file open read_mode is file_name; variable result: integer_vector(1 to len); variable index: integer := 1; begin while not endfile(data_file) and index <= len loop read(data_file, result(index)); index:= index + 1; end loop; return result; end;

File open and close

• In the examples discussed thus far:

• we have opened the files at definition.

• we have implicitly closed the files.

• VHDL permits explicit opening and closing of

files.

Open errors

status_error: file object previously open and associated with a physical file.

name_error: in read mode indicates file does not exist. in write mode indicates file cannot be created. in append mode indicates both.

mode_error: indicates file cannot be opened in the specified mode.

File procedure parameters

procedure read_transform ( file f: transform_file;

variable transform : out transform_array) is

begin

for i in transform’range(1) loop for j in transform’range(2) loop if endfile(f) then report “unexpected end of file” severity error; return end if; read (f,transform(i,j)); end loop; end loop;

end;

VHDL

does not

permit

reading

or

writing

of 2-D

arrays.

Package textio

type line is access string;

type text is file of string;

type side is (right,left);

subtype width is natural;

file input: text open read_mode is “std_input”;

file output: text open write_mode is “std_output”;

procedure readline (file f: text; L: inout line);

procedure writeline (file f: text; L: inout line);

Using textio procedures

• The type “access” denotes a pointer in VHDL.

• textio works with a pointer to a line of

text or string.

• A pointer is an object that has the starting address

of the line of text.

Pointer String

• “readline” and “writeline” read and write an entire

string that is pointed to by the pointer.

textio read operation

  • Every read operation that reads a data type other

than “character” skips whitespace (ws) characters: Space,

Tab. Reading a character does not skip ws chars since they

are legitimate characters; if they need to be skipped, then that does need to be done explicitly at the point of the ws character w/ a read: read(L,c), where “c” is of type character.

  • If the line contains the following items: fred “cat” 1001010 12 -4.7 a 10 ns

readline(file_id,L); read (L,s); -- L is a string, s is a string read (L,s); read (L,bv); -- bv is a bit_vector read (L,i); -- i is an integer read (L,r); -- r is a real read (L,c); -- c is a character read (L,t); -- t is a time

textio write procedures

procedure write (L : inout line; value: in bit; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in bit_vector; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in boolean; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in character; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in integer; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in real; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in string; justified: in side := right; field: in width := 0); procedure write (L : inout line; value: in time; justified: in side := right; field: in width; unit: in time:= ns);Docsity.com