假设我有以下类型定义,它依赖于常量来指示记录成员的向量长度:
type point_t is record
x: std_logic_vector(X_WIDTH-1 downto 0);
y: std_logic_vector(Y_WIDTH-1 downto 0);
end record;
Run Code Online (Sandbox Code Playgroud)
我想将这些记录转换为std_logic_vectors,将它们放入FIFO中.目前我使用以下代码:
PROCEDURE encodepoint(signal pnt: in point_t;
signal d: out std_logic_vector(POINT_ENC_WIDTH-1 downto 0)) is
variable top: integer := 0;
begin
top := X_WIDTH-1;
d(top downto 0) <= pnt.x;
top := top + Y_WIDTH;
d(top downto top-X_WIDTH+1) <= sl.y;
d(d'left downto top+1) <= (others => '0');
end;
Run Code Online (Sandbox Code Playgroud)
此代码在许多方面都不是最理想的.例如,它要求我始终将POINT_ENC_WIDTH正确设置为足够大的值,以允许d保存整个序列化记录.它依靠程序员来做非常机械的工作.例如,对于记录的每个成员,例如x,在代码中X_WIDTH出现两次,一次x与下一个成员直接连接,一次与下一个成员连接,y.这很快就会变得乏味.如果我通过添加其他字段来更改记录的定义,我必须更新序列化和(非常相似)反序列化代码,我可能会忘记这一点.当我删除字段时,至少编译器会抱怨.
因此,这引出了我的问题:是否有简单,自动或至少准自动的方式将VHDL记录转换为std_logic_vectors而无需借助于手动编写的序列化/反序列化代码?我知道特定的编码并不重要,因为我在内部使用记录,并且明确指定了最终输出格式并将手动实现.
我记得在Perl的日子里," use strict "语句会导致运行时进行额外的验证.是否有Groovy的等价物?
我不喜欢在运行时被编译时可以检测到的东西咬住,比如将一些参数传递给构造函数.
我想要一个实际的术语.标签线?
我无法在谷歌上找到他们的参考,因为我不知道该搜索什么!
我想看看Gedit是否有这样的东西.
我精通Java,并开始尝试使用Groovy.因为这两者集成得很好,我发现自己用Java写作,因为它很容易.您可以提供哪些具体提示,以加快我使用Groovy的工作?
意义 - 在什么领域中groovy优于java,我应该在哪里坚持Java?
我正在使用Flash CS4和AS3.我想要一个定时器以50 ms的间隔调用一个函数100次.然而,计时器需要的时间比它应该的长得多,在100次重复后,它会增加1677毫秒(1.677秒!).我在这里遗漏了什么或计时器不准确吗?
码
function test(event:TimerEvent):void{
trace("GetTimer(): " + getTimer() + " || Timer.currentCount: " + _timer.currentCount);
}
var _timer:Timer = new Timer(50, 100);
_timer.addEventListener(TimerEvent.TIMER, test);
_timer.start();
Run Code Online (Sandbox Code Playgroud)
跟踪输出:
GetTimer():74 || Timer.currentCount:1
GetTimer():140 || Timer.currentCount:2
GetTimer():209 || Timer.currentCount:3
GetTimer():275 || Timer.currentCount:4
GetTimer():340 || Timer.currentCount:5
GetTimer():407 || Timer.currentCount:6
GetTimer():476 || Timer.currentCount:7
GetTimer():542 || Timer.currentCount:8
GetTimer():608 || Timer.currentCount:9
GetTimer():677 || Timer.currentCount:10
......
GetTimer():3340 || Timer.currentCount:50
......
GetTimer():6677 || Timer.currentCount:100
感谢帮助.
问候,
克里斯
我正在尝试在我的应用程序中使用HttpURLConnection.我将我的请求方法设置为'GET',但是当我尝试检索输出流时,该方法将更改为'POST'!我不确定是什么原因,但是当我使用'POST'发送请求时,我的JSON服务器(我使用JAX-RS)会返回一个空白页面.
这是我的代码片段:
// Create the connection
HttpURLConnection con = (HttpURLConnection) new URL(getUrl() + uriP).openConnection();
// Add cookies if necessary
if (cookies != null) {
for (String cookie : cookies) {
con.addRequestProperty("Cookie", cookie);
Log.d("JSONServer", "Added cookie: " + cookie);
}
}
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
con.setRequestMethod("GET");
con.setConnectTimeout(20000);
// Add 'Accept' property in header otherwise JAX-RS/CXF will answer a XML stream
con.addRequestProperty("Accept", "application/json");
// Get the output stream
OutputStream os = con.getOutputStream();
// !!!!! HERE THE REQUEST METHOD HAS BEEN CHANGED !!!!!!
OutputStreamWriter …Run Code Online (Sandbox Code Playgroud) 朋友我正在从我的Android设备发送短信,在这里我在edittext框中手动输入号码,我有消息要发送,这里我如何检查输入的电话号码是从电话目录中的有效号码.帮助我..
我有一个像这样的RelativeLayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip">
<Button
android:id="@+id/negativeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dip"
android:textColor="#ffffff"
android:layout_alignParentLeft="true"
android:background="@drawable/black_menu_button"
android:layout_marginLeft="5dip"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
<Button
android:id="@+id/positiveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dip"
android:textColor="#ffffff"
android:layout_alignParentRight="true"
android:background="@drawable/blue_menu_button"
android:layout_marginRight="5dip"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我希望能够以编程方式设置positiveButton相同的效果:
android:layout_centerInParent="true"
Run Code Online (Sandbox Code Playgroud)
我怎样才能以编程方式进行此操作?
嗨,在.net 4中的这段代码中,我使用了gzipstream的copyto方法
System.IO.MemoryStream ms = new System.IO.MemoryStream(byteArray);
GZipStream DecompressOut = new GZipStream(ms, System.IO.Compression.CompressionMode.Decompress);
MemoryStream outmem = new MemoryStream();
DecompressOut.copyto(outmem);
FileStream outFile = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(outFile);
Run Code Online (Sandbox Code Playgroud)
我怎样才能直接将GZipStream写入MemoryStream或FileStream?
前几天我坐着一个正则表达式问题.最终我用不同的方式解决了它,没有正则表达式,但我仍然想知道你是怎么做的:)
我遇到的问题是通过自动脚本运行svn update,我想检测冲突.使用或不使用正则表达式执行此操作是微不足道的,但它让我想到了一个更加模糊的问题:如何在空白的固定长度字段内完全匹配一个字符?
例如,假设我们想在六字节宽字段内匹配"C":
"C " MATCH " C " MATCH " C C " NO MATCH " M " NO MATCH " " NO MATCH "C " NO MATCH (7 characters, not 6) " C " NO MATCH (5 characters, not 6)