SlideShare une entreprise Scribd logo
1  sur  10
--------------------------------------------------------------------------<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 />
Auxiliary
Auxiliary
Auxiliary
Auxiliary
Auxiliary
Auxiliary
Auxiliary
Auxiliary
Auxiliary

Contenu connexe

Tendances

Learning sed and awk
Learning sed and awkLearning sed and awk
Learning sed and awkYogesh Sawant
 
Advanced perl finer points ,pack&amp;unpack,eval,files
Advanced perl   finer points ,pack&amp;unpack,eval,filesAdvanced perl   finer points ,pack&amp;unpack,eval,files
Advanced perl finer points ,pack&amp;unpack,eval,filesShankar D
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25Techvilla
 
Perl6 for-beginners
Perl6 for-beginnersPerl6 for-beginners
Perl6 for-beginnersJens Rehsack
 
CyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation ProcessCyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation ProcessThomas Gregory
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and CEleanor McHugh
 
Python and sysadmin I
Python and sysadmin IPython and sysadmin I
Python and sysadmin IGuixing Bai
 
Argparse: Python command line parser
Argparse: Python command line parserArgparse: Python command line parser
Argparse: Python command line parserTimo Stollenwerk
 
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom GregoryExploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom Gregoryzakiakhmad
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programmingkayalkarnan
 
101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4Acácio Oliveira
 
3.1 gnu and unix commands v4
3.1 gnu and unix commands v43.1 gnu and unix commands v4
3.1 gnu and unix commands v4Acácio Oliveira
 

Tendances (20)

Learning sed and awk
Learning sed and awkLearning sed and awk
Learning sed and awk
 
Advanced perl finer points ,pack&amp;unpack,eval,files
Advanced perl   finer points ,pack&amp;unpack,eval,filesAdvanced perl   finer points ,pack&amp;unpack,eval,files
Advanced perl finer points ,pack&amp;unpack,eval,files
 
Unit v
Unit vUnit v
Unit v
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25
 
Perl6 for-beginners
Perl6 for-beginnersPerl6 for-beginners
Perl6 for-beginners
 
Sp ch05
Sp ch05Sp ch05
Sp ch05
 
CyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation ProcessCyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation Process
 
Mysql
MysqlMysql
Mysql
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
Python and sysadmin I
Python and sysadmin IPython and sysadmin I
Python and sysadmin I
 
Foxpro (1)
Foxpro (1)Foxpro (1)
Foxpro (1)
 
Argparse: Python command line parser
Argparse: Python command line parserArgparse: Python command line parser
Argparse: Python command line parser
 
Mips1
Mips1Mips1
Mips1
 
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom GregoryExploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
 
101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4
 
Newdoc maxis
Newdoc maxisNewdoc maxis
Newdoc maxis
 
3.1 gnu and unix commands v4
3.1 gnu and unix commands v43.1 gnu and unix commands v4
3.1 gnu and unix commands v4
 
Unit5
Unit5Unit5
Unit5
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 

Similaire à Auxiliary

Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Parkpointstechgeeks
 
Lab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docxLab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docxDIPESH30
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly LanguageMotaz Saad
 
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)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 applicationsperl usage at database applications
perl usage at database applicationsJoe Jiang
 
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataKernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataAnne Nicolas
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.pptyuvrajkeshri
 
The Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core ApiThe Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core ApiNTT DATA Americas
 
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Tom Paulus
 
Phil Bartie QGIS PLPython
Phil Bartie QGIS PLPythonPhil Bartie QGIS PLPython
Phil Bartie QGIS PLPythonRoss McDonald
 
Lua by Ong Hean Kuan
Lua by Ong Hean KuanLua by Ong Hean Kuan
Lua by Ong Hean Kuanfossmy
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewDan Morrill
 

Similaire à Auxiliary (20)

Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
 
Lab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docxLab11.cppLab11.cpp.docx
Lab11.cppLab11.cpp.docx
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
IO Streams, Files and Directories
IO Streams, Files and DirectoriesIO Streams, Files and Directories
IO Streams, Files and Directories
 
Program For Parsing2
Program For Parsing2Program 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)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 applicationsperl 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 dataKernel 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.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
The Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core ApiThe Ruby On Rails I18n Core Api
The Ruby On Rails I18n Core Api
 
Apache pig
Apache pigApache pig
Apache pig
 
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1
 
Phil Bartie QGIS PLPython
Phil Bartie QGIS PLPythonPhil Bartie QGIS PLPython
Phil Bartie QGIS PLPython
 
Lua by Ong Hean Kuan
Lua by Ong Hean KuanLua by Ong Hean Kuan
Lua by Ong Hean Kuan
 
Having Fun Programming!
Having Fun Programming!Having Fun Programming!
Having Fun Programming!
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overview
 
About Go
About GoAbout Go
About Go
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Python build your security tools.pdf
Python build your security tools.pdfPython build your security tools.pdf
Python build your security tools.pdf
 

Plus de ececourse

Machine Problem 2
Machine Problem 2Machine Problem 2
Machine Problem 2ececourse
 
Machine Problem 1
Machine Problem 1Machine Problem 1
Machine Problem 1ececourse
 
Chapter 2 Hw
Chapter 2 HwChapter 2 Hw
Chapter 2 Hwececourse
 
Chapter 2 Part2 C
Chapter 2 Part2 CChapter 2 Part2 C
Chapter 2 Part2 Cececourse
 
C:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 BC:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 Bececourse
 
Chapter 2 Part2 A
Chapter 2 Part2 AChapter 2 Part2 A
Chapter 2 Part2 Aececourse
 
Chapter 2 Part1
Chapter 2 Part1Chapter 2 Part1
Chapter 2 Part1ececourse
 

Plus de ececourse (14)

Chapter 5 c
Chapter 5 cChapter 5 c
Chapter 5 c
 
Chapter 5 b
Chapter 5  bChapter 5  b
Chapter 5 b
 
Chapter 5 a
Chapter 5 aChapter 5 a
Chapter 5 a
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Mem Tb
Mem TbMem Tb
Mem Tb
 
Machine Problem 2
Machine Problem 2Machine Problem 2
Machine Problem 2
 
Machine Problem 1
Machine Problem 1Machine Problem 1
Machine Problem 1
 
Chapter 2 Hw
Chapter 2 HwChapter 2 Hw
Chapter 2 Hw
 
Chapter 2 Part2 C
Chapter 2 Part2 CChapter 2 Part2 C
Chapter 2 Part2 C
 
C:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 BC:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 B
 
Chapter 2 Part2 A
Chapter 2 Part2 AChapter 2 Part2 A
Chapter 2 Part2 A
 
Chapter1
Chapter1Chapter1
Chapter1
 
Chapter 2 Part1
Chapter 2 Part1Chapter 2 Part1
Chapter 2 Part1
 

Dernier

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Auxiliary

  • 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 />