⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch11.11.htm

📁 介绍asci设计的一本书
💻 HTM
字号:
<HTML>

<HEAD>

  <META NAME="GENERATOR" CONTENT="Adobe PageMill 2.0 Mac">

  

  <TITLE> 11.11&nbsp;&nbsp;&nbsp;Altering Parameters</TITLE>

</HEAD><!--#include file="top.html"--><!--#include file="header.html"--><br><!--#include file="AmazonAsic.html"-->



<P><A NAME="pgfId=137295"></A><HR ALIGN="LEFT"></P>

<P><A HREF="CH11.htm">Chapter&nbsp;start</A></P>

<P><A HREF="CH11.10.htm">Previous page</A></P>

<P><A HREF="CH11.12.htm">Next page</A></P>

<H1>11.11&nbsp;&nbsp;&nbsp;Altering Parameters</H1>

<P><P CLASS="BodyAfterHead"><A NAME="pgfId=5772"></A>Here is an example

of a module that uses a parameter [Verilog LRM3.10, 12.2]:</P>

<PRE>

<B>module</B> Vector_And(Z, A, B);

&nbsp;&nbsp;<B>parameter</B> CARDINALITY = 1;

&nbsp;&nbsp;<B>input</B> [CARDINALITY-1:0] A, B;

<B>&nbsp;&nbsp;output</B> [CARDINALITY-1:0] Z;

&nbsp;&nbsp;<B>wire </B>[CARDINALITY-1:0]<B> </B>Z = A &amp; B;

<B>endmodule</B></PRE>

<P><P CLASS="Body"><A NAME="pgfId=6312"></A>We can override this parameter

when we instantiate the module as follows:</P>

<PRE>

<B>module</B> Four_And_Gates(OutBus, InBusA, InBusB);

&nbsp;&nbsp;<B>input</B> [3:0] InBusA, InBusB; <B>output</B> [3:0] OutBus;

&nbsp;&nbsp;Vector_And #(4) My_AND(OutBus, InBusA, InBusB); // 4 AND gates

<B>endmodule</B></PRE>

<P><P CLASS="Body"><A NAME="pgfId=5805"></A>The parameters of a module have

local scope, but we may override them using a <B>defparam</B> statement

and a hierarchical name, as in the following example:</P>

<PRE>

<B>module</B> And_Gates(OutBus, InBusA, InBusB);

&nbsp;&nbsp;<B>parameter</B> WIDTH = 1;

&nbsp;&nbsp;<B>input</B> [WIDTH-1:0] InBusA, InBusB; <B>output</B> [WIDTH-1:0] OutBus;

&nbsp;&nbsp;Vector_And #(WIDTH) My_And(OutBus, InBusA, InBusB);

<B>endmodule</B> 

<B>module</B> Super_Size; <B>defparam </B>And_Gates.WIDTH = 4; <B>endmodule</B></PRE>

<P><HR ALIGN="LEFT"></P>

<P><A HREF="CH11.htm">Chapter&nbsp;start</A></P>

<P><A HREF="CH11.10.htm">Previous page</A></P>

<P><A HREF="CH11.12.htm">Next page</A>

</BODY>



<!--#include file="Copyright.html"--><!--#include file="footer.html"-->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -