Soumettre la recherche
Mettre en ligne
Auxiliary package for MIPS memory functions
•
Télécharger en tant que DOCX, PDF
•
0 j'aime
•
251 vues
Titre amélioré par l'IA
E
ececourse
Suivre
Technologie
Signaler
Partager
Signaler
Partager
1 sur 10
Télécharger maintenant
Recommandé
01c shell
01c shell
Kevin Lee
File handling in c language
File handling in c language
Harish Gyanani
The bones of a nice Python script
The bones of a nice Python script
saniac
Unit vii wp ppt
Unit vii wp ppt
Bhavsingh Maloth
Regexp Master
Regexp Master
Paolo Marcatili
Vcs26
Vcs26
Malikireddy Bramhananda Reddy
runtimestack
runtimestack
Teddy Hsiung
Data structures
Data structures
gayatrigayu1
Recommandé
01c shell
01c shell
Kevin Lee
File handling in c language
File handling in c language
Harish Gyanani
The bones of a nice Python script
The bones of a nice Python script
saniac
Unit vii wp ppt
Unit vii wp ppt
Bhavsingh Maloth
Regexp Master
Regexp Master
Paolo Marcatili
Vcs26
Vcs26
Malikireddy Bramhananda Reddy
runtimestack
runtimestack
Teddy Hsiung
Data structures
Data structures
gayatrigayu1
Learning sed and awk
Learning sed and awk
Yogesh Sawant
Advanced perl finer points ,pack&unpack,eval,files
Advanced perl finer points ,pack&unpack,eval,files
Shankar D
Unit v
Unit v
kannaki
Raspberry pi Part 25
Raspberry pi Part 25
Techvilla
Perl6 for-beginners
Perl6 for-beginners
Jens Rehsack
Sp ch05
Sp ch05
Shi-Wu Lo(Gmail)
CyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation Process
Thomas Gregory
Mysql
Mysql
HAINIRMALRAJ
Implementing Software Machines in Go and C
Implementing Software Machines in Go and C
Eleanor McHugh
Python and sysadmin I
Python and sysadmin I
Guixing Bai
Foxpro (1)
Foxpro (1)
piyushrajsinha
Argparse: Python command line parser
Argparse: Python command line parser
Timo Stollenwerk
Mips1
Mips1
Stefano Salvatori
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
zakiakhmad
32 shell-programming
32 shell-programming
kayalkarnan
101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4
Acácio Oliveira
Newdoc maxis
Newdoc maxis
Shikin Hamdin
3.1 gnu and unix commands v4
3.1 gnu and unix commands v4
Acácio Oliveira
Unit5
Unit5
mrecedu
C Homework Help
C Homework Help
Programming Homework Help
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
pointstechgeeks
Lab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docx
DIPESH30
Contenu connexe
Tendances
Learning sed and awk
Learning sed and awk
Yogesh Sawant
Advanced perl finer points ,pack&unpack,eval,files
Advanced perl finer points ,pack&unpack,eval,files
Shankar D
Unit v
Unit v
kannaki
Raspberry pi Part 25
Raspberry pi Part 25
Techvilla
Perl6 for-beginners
Perl6 for-beginners
Jens Rehsack
Sp ch05
Sp ch05
Shi-Wu Lo(Gmail)
CyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation Process
Thomas Gregory
Mysql
Mysql
HAINIRMALRAJ
Implementing Software Machines in Go and C
Implementing Software Machines in Go and C
Eleanor McHugh
Python and sysadmin I
Python and sysadmin I
Guixing Bai
Foxpro (1)
Foxpro (1)
piyushrajsinha
Argparse: Python command line parser
Argparse: Python command line parser
Timo Stollenwerk
Mips1
Mips1
Stefano Salvatori
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
zakiakhmad
32 shell-programming
32 shell-programming
kayalkarnan
101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4
Acácio Oliveira
Newdoc maxis
Newdoc maxis
Shikin Hamdin
3.1 gnu and unix commands v4
3.1 gnu and unix commands v4
Acácio Oliveira
Unit5
Unit5
mrecedu
C Homework Help
C Homework Help
Programming Homework Help
Tendances
(20)
Learning sed and awk
Learning sed and awk
Advanced perl finer points ,pack&unpack,eval,files
Advanced perl finer points ,pack&unpack,eval,files
Unit v
Unit v
Raspberry pi Part 25
Raspberry pi Part 25
Perl6 for-beginners
Perl6 for-beginners
Sp ch05
Sp ch05
CyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation Process
Mysql
Mysql
Implementing Software Machines in Go and C
Implementing Software Machines in Go and C
Python and sysadmin I
Python and sysadmin I
Foxpro (1)
Foxpro (1)
Argparse: Python command line parser
Argparse: Python command line parser
Mips1
Mips1
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
32 shell-programming
32 shell-programming
101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4
Newdoc maxis
Newdoc maxis
3.1 gnu and unix commands v4
3.1 gnu and unix commands v4
Unit5
Unit5
C Homework Help
C Homework Help
Similaire à Auxiliary package for MIPS memory functions
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
pointstechgeeks
Lab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docx
DIPESH30
Introduction to Assembly Language
Introduction to Assembly Language
Motaz Saad
C to perl binding
C to perl binding
Shmuel Fomberg
IO Streams, Files and Directories
IO Streams, Files and Directories
Krasimir Berov (Красимир Беров)
Program For Parsing2
Program For Parsing2
Michelle Crapo
various tricks for remote linux exploits by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits by Seok-Ha Lee (wh1ant)
CODE BLUE
perl usage at database applications
perl usage at database applications
Joe Jiang
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Anne Nicolas
file_handling_in_c.ppt
file_handling_in_c.ppt
yuvrajkeshri
The Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core Api
NTT DATA Americas
Apache pig
Apache pig
Jigar Parekh
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1
Tom Paulus
Phil Bartie QGIS PLPython
Phil Bartie QGIS PLPython
Ross McDonald
Lua by Ong Hean Kuan
Lua by Ong Hean Kuan
fossmy
Having Fun Programming!
Having Fun Programming!
Aaron Patterson
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overview
Dan Morrill
About Go
About Go
Jongmin Kim
Perl Presentation
Perl Presentation
Sopan Shewale
Python build your security tools.pdf
Python build your security tools.pdf
TECHNOLOGY CONTROL CO.
Similaire à Auxiliary package for MIPS memory functions
(20)
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
Lab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docx
Introduction to Assembly Language
Introduction to Assembly Language
C to perl binding
C to perl binding
IO Streams, Files and Directories
IO Streams, Files and Directories
Program For Parsing2
Program For Parsing2
various tricks for remote linux exploits by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits by Seok-Ha Lee (wh1ant)
perl usage at database applications
perl usage at database applications
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
file_handling_in_c.ppt
file_handling_in_c.ppt
The Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core Api
Apache pig
Apache pig
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1
Phil Bartie QGIS PLPython
Phil Bartie QGIS PLPython
Lua by Ong Hean Kuan
Lua by Ong Hean Kuan
Having Fun Programming!
Having Fun Programming!
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overview
About Go
About Go
Perl Presentation
Perl Presentation
Python build your security tools.pdf
Python build your security tools.pdf
Plus de ececourse
Chapter 5 c
Chapter 5 c
ececourse
Chapter 5 b
Chapter 5 b
ececourse
Chapter 5 a
Chapter 5 a
ececourse
Chapter 4
Chapter 4
ececourse
Chapter 3
Chapter 3
ececourse
Mem Tb
Mem Tb
ececourse
Machine Problem 2
Machine Problem 2
ececourse
Machine Problem 1
Machine Problem 1
ececourse
Chapter 2 Hw
Chapter 2 Hw
ececourse
Chapter 2 Part2 C
Chapter 2 Part2 C
ececourse
C:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 B
ececourse
Chapter 2 Part2 A
Chapter 2 Part2 A
ececourse
Chapter1
Chapter1
ececourse
Chapter 2 Part1
Chapter 2 Part1
ececourse
Plus de ececourse
(14)
Chapter 5 c
Chapter 5 c
Chapter 5 b
Chapter 5 b
Chapter 5 a
Chapter 5 a
Chapter 4
Chapter 4
Chapter 3
Chapter 3
Mem Tb
Mem Tb
Machine Problem 2
Machine Problem 2
Machine Problem 1
Machine Problem 1
Chapter 2 Hw
Chapter 2 Hw
Chapter 2 Part2 C
Chapter 2 Part2 C
C:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 B
Chapter 2 Part2 A
Chapter 2 Part2 A
Chapter1
Chapter1
Chapter 2 Part1
Chapter 2 Part1
Dernier
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
panagenda
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
IES VE
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
BookNet Canada
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
LoriGlavin3
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
Inflectra
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
marketing932765
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
ThousandEyes
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
Pixlogix Infotech
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
LoriGlavin3
How to write a Business Continuity Plan
How to write a Business Continuity Plan
Databarracks
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Nikki Chapple
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
Kari Kakkonen
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
LoriGlavin3
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
Knoldus Inc.
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
itnewsafrica
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
fnnc6jmgwh
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
Neo4j
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
BookNet Canada
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
Kaya Weers
Dernier
(20)
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
How to write a Business Continuity Plan
How to write a Business Continuity Plan
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
Auxiliary package for MIPS memory functions
1.
--------------------------------------------------------------------------<br />-- Download
and rename the file to auxiliary.vhd<br />-- AUB<br />-- EECE 321 - Computer Organization, Spring 2009<br />-- Author: M. M.<br />--------------------------------------------------------------------------<br />-- Description: Auxiliary package including user-defined functions<br />--------------------------------------------------------------------------<br />library ieee;<br />use ieee.std_logic_1164.all;<br />use ieee.std_logic_unsigned.all;<br />use ieee.std_logic_arith.all;<br />use ieee.std_logic_misc.all;<br />USE ieee.std_logic_textio.all;<br />USE std.textio.all;<br />-- ---------------------------------------------------------------------------------<br />-- NOTES:<br />-- ---------------------------------------------------------------------------------<br />-- To convert STD_LOGIC_VECTOR to INTEGER, use the built-in function quot; conv_integerquot; <br />-- CONV_INTEGER(ARG: STD_LOGIC_VECTOR) return INTEGER;<br />-- Ex: if x is a STD_LOGIC_VECTOR, then<br />-- y := conv_integer(x) converts x to unsigned integer<br />-- ---------------------------------------------------------------------------------<br />--<br />-- To convert from INTEGER to STD_LOGIC_VECTOR, use the built-in function quot; conv_std_logic_vectorquot; <br />-- CONV_STD_LOGIC_VECTOR(ARG: INTEGER; SIZE: INTEGER) return STD_LOGIC_VECTOR;<br />-- Ex: if y is an integer, then<br />-- x := conv_std_logic_vector(y,4) converts the integer y into a std_logic_vector of width 4<br />-- ---------------------------------------------------------------------------------<br />--<br />-- declare functions and data types here<br />package auxiliary is<br />----------------------------------------------------------------------------------<br /> -- CONSTANTS<br /> ----------------------------------------------------------------------------------<br />CONSTANT MIPS_WORD_SIZE_IN_BYTES : NATURAL := 4;<br />----------------------------------------------------------------------------------<br /> -- DATA TYPES<br /> ----------------------------------------------------------------------------------<br />SUBTYPE MIPS_WORD is STD_LOGIC_VECTOR(MIPS_WORD_SIZE_IN_BYTES * 8 - 1 DOWNTO 0);<br />TYPE MEM_ARRAY is array (INTEGER range <>) of MIPS_WORD;<br />----------------------------------------------------------------------------------<br /> -- USER-DEFINED FUNCTIONS AND PROCEDURES<br /> ----------------------------------------------------------------------------------<br />PROCEDURE read_hex_2_natural(L: INOUT LINE; width: IN NATURAL; natnum : OUT NATURAL);<br />PROCEDURE read_hex_2_word(L: INOUT LINE; width: IN NATURAL; WORD : OUT STD_LOGIC_VECTOR);<br />PROCEDURE init_mem(fname : IN STRING; mem : OUT MEM_ARRAY);<br />PROCEDURE copy_mem_2_file(fname : IN STRING; mem : IN MEM_ARRAY);<br />FUNCTION load_word(mem : IN MEM_ARRAY; byte_addr : IN NATURAL) RETURN MIPS_WORD;<br />PROCEDURE store_word(mem : OUT MEM_ARRAY; word : MIPS_WORD; byte_addr : IN NATURAL);<br />-- add your functions below ...<br />end auxiliary;<br />package body auxiliary is<br />----------------------------------------------------------------<br />-- Read a hexadecimal string and converts it to a natural number<br />----------------------------------------------------------------<br />PROCEDURE read_hex_2_natural(L: INOUT LINE; width: IN NATURAL; natnum : OUT NATURAL) IS<br />VARIABLE result : NATURAL := 0;<br />VARIABLE ch : CHARACTER;<br />BEGIN<br />FOR i in 1 to width LOOP<br />read(L,ch);<br />IF '0' <= ch AND ch <= '9' THEN<br />result := result*16 + character'pos(ch) - character'pos('0');<br />ELSIF 'A' <= ch AND ch <= 'F' THEN<br />result := result*16 + character'pos(ch) - character'pos('A') + 10;<br />ELSIF 'a' <= ch AND ch <= 'f' THEN<br />result := result*16 + character'pos(ch) - character'pos('a') + 10;<br />ELSE<br />report quot; Format error in input file. Line quot; & integer'image(i) & quot; . quot; severity failure;<br />END IF; <br />END LOOP;<br />natnum := result;<br />END read_hex_2_natural;<br />----------------------------------------------------------------<br />-- Read a hexadecimal string and converts it to a STD_LOGIC_VECTOR<br />----------------------------------------------------------------<br />PROCEDURE read_hex_2_word(L: INOUT LINE; width: IN NATURAL; WORD : OUT STD_LOGIC_VECTOR) IS<br />VARIABLE digit : NATURAL;<br />VARIABLE r : NATURAL := 0;<br />VARIABLE ch : CHARACTER;<br />BEGIN<br />-- first check if width of 'word' is equal to width<br />IF width /= (WORD'length)/4 THEN<br />report quot; Input argument width in function 'read_hex_2_vector' incompatible with output width.quot; severity failure;<br />END IF; <br />FOR i in 1 to width LOOP<br />read(L,ch);<br />IF '0' <= ch AND ch <= '9' THEN<br />digit := character'pos(ch) - character'pos('0');<br />ELSIF 'A' <= ch AND ch <= 'F' THEN<br />digit := character'pos(ch) - character'pos('A') + 10;<br />ELSIF 'a' <= ch AND ch <= 'f' THEN<br />digit := character'pos(ch) - character'pos('a') + 10;<br />ELSE<br />report quot; Format error in input file.quot; severity failure;<br />END IF; <br />WORD(31-r DOWNTO 28-r) := conv_std_logic_vector(digit,4);<br />r := r + 4;<br />END LOOP;<br />END read_hex_2_word;<br />----------------------------------------------------------------<br />-- Initializes memory from a file<br />----------------------------------------------------------------<br />PROCEDURE init_mem(fname : IN STRING; mem : OUT MEM_ARRAY) IS<br />FILE binary_file: text;<br />VARIABLE open_status : file_open_status;<br />VARIABLE L: LINE;<br />VARIABLE ch : CHARACTER;<br />VARIABLE line_number : NATURAL := 0;<br />VARIABLE addr : NATURAL;<br />VARIABLE word : MIPS_WORD;<br />BEGIN<br />-- open file<br />file_open(open_status, binary_file, fname, read_mode);<br />-- check status, report error in case something is wrong with input simulation file<br />IF open_status /= open_ok then<br />report file_open_status'image(open_status) & quot; WHILE opening file quot; & fname<br /> severity failure; <br /> END IF;<br />-- First, write zeros in all entries<br />FOR i in mem'RANGE LOOP <br />mem(i) := (OTHERS => '0');<br />END LOOP;<br />-- Fill entries of memory from the input file<br />WHILE NOT endfile(binary_file) LOOP<br />readline(binary_file, L);<br />line_number := line_number + 1;<br />read_hex_2_natural(L,8,addr);<br />read(L,ch); -- space between address and data<br />read_hex_2_word(L,8,word);<br />mem(addr/4) := word;<br />END LOOP;<br /> <br />END init_mem;<br />----------------------------------------------------------------<br />-- Copies the contents of memory into a file<br />----------------------------------------------------------------<br />PROCEDURE copy_mem_2_file(fname : IN STRING; mem : IN MEM_ARRAY) IS<br />FILE binary_file: text;<br />VARIABLE open_status : file_open_status;<br />VARIABLE L: LINE;<br />VARIABLE line_number : NATURAL := 0;<br />VARIABLE addr : MIPS_WORD;<br />VARIABLE word : MIPS_WORD;<br />VARIABLE nibble : STD_LOGIC_VECTOR(3 DOWNTO 0);<br />BEGIN<br />-- open file<br />file_open(open_status, binary_file, fname, write_mode);<br />-- check status, report error in case something is wrong with input simulation file<br />IF open_status /= open_ok then<br />report file_open_status'image(open_status) & quot; WHILE opening file quot; & fname<br /> severity failure; <br /> END IF;<br />-- Fill entries of memory from the input file<br />FOR j in mem'range LOOP<br />-- assemble address field in hexadecimal<br />addr := conv_std_logic_vector(4*line_number,addr'length);<br />for i in 0 to 7 loop<br />nibble := addr(31-4*i downto 28-4*i); <br />hwrite(L,nibble,FIELD=>1,JUSTIFIED=>left);<br />end loop;<br />-- fill space<br />write(L,STRING'(quot; quot; ));<br />-- assemble data field in hexadecimal<br />word := mem(line_number);<br />for i in 0 to 7 loop<br />nibble := word(31-4*i downto 28-4*i);<br />hwrite(L,nibble,FIELD=>1,JUSTIFIED=>left);<br />end loop;<br />-- advance line number<br />line_number := line_number + 1;<br />-- print line to output file<br />writeline(binary_file,L);<br />END LOOP;<br /> <br />END copy_mem_2_file;<br />----------------------------------------------------------------<br />-- Loads a word from memory (address is byte address)<br />----------------------------------------------------------------<br />FUNCTION load_word(mem : IN MEM_ARRAY; byte_addr : IN NATURAL) RETURN MIPS_WORD IS<br />VARIABLE word : MIPS_WORD;<br />BEGIN<br />-- check byte address falls in memory range or is a multiple of the number of bytes within a word<br />IF (byte_addr < 0) OR <br />(byte_addr >= MIPS_WORD_SIZE_IN_BYTES * mem'length) OR<br />(byte_addr mod MIPS_WORD_SIZE_IN_BYTES /= 0)THEN<br />report quot; Invalid byte address in function 'load_word': quot; & integer'image(byte_addr)<br /> severity failure; <br /> END IF; <br />word := mem(byte_addr/4); <br />return word;<br /> <br />END load_word;<br />----------------------------------------------------------------<br />-- Stores a word into memory (address is byte address)<br />----------------------------------------------------------------<br />PROCEDURE store_word(mem : OUT MEM_ARRAY; word : MIPS_WORD; byte_addr : IN NATURAL) IS<br />BEGIN<br />-- check byte address falls in memory range or is a multiple of the number of bytes within a word<br />IF (byte_addr < 0) OR <br />(byte_addr >= MIPS_WORD_SIZE_IN_BYTES * mem'length) OR<br />(byte_addr mod MIPS_WORD_SIZE_IN_BYTES /= 0)THEN<br />report quot; Invalid byte address in function 'store_word': quot; & integer'image(byte_addr)<br /> severity failure; <br /> END IF; <br />mem(byte_addr/4) := word; <br />END store_word;<br />END auxiliary;<br />
Télécharger maintenant