Skip to content

Instantly share code, notes, and snippets.

@vlsi1217
vlsi1217 / CircBuffer.c
Last active August 29, 2015 14:21 — forked from harshkn/CircBuffer.c
typedef struct circular_buffer
{
void *buffer; // data buffer
void *buffer_end; // end of data buffer
size_t capacity; // maximum number of items in the buffer
size_t count; // number of items in the buffer
size_t sz; // size of each item in the buffer
void *head; // pointer to head
void *tail; // pointer to tail
} circular_buffer;
@vlsi1217
vlsi1217 / testEmb.java
Last active August 29, 2015 14:21
test embedding
package freq2_tony;
/**
* We must organize the computation so that all entries that we need are filled in prior to using
* them in subsequent computations.
*/
import java.util.*;
/**
* 今天听了段公子的DP, 里面经典的2D->1D DP优化的第一题就是coin change. 这对于理解distinct subsequence帮助很大.
@vlsi1217
vlsi1217 / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@vlsi1217
vlsi1217 / dmem.java
Created May 6, 2014 07:45
simple java to generate initial value for dmem for signed extended 32 bit binary from integer
import java.util.*;
import java.lang.*;
import java.io.*;
class dmem
{
public static void main(String []args){
System.out.println("Hello World");
for(int i=1; i<65; i++){
System.out.println(String.format("%32s", Integer.toBinaryString(i)).replace(' ', '0'));
}
@vlsi1217
vlsi1217 / i2c_base.cpp
Created March 6, 2014 02:41
i2c driver for ARM m3 from CMPE 244, Spring 2014---Need to finish the FSM.
/*
* SocialLedge.com - Copyright (C) 2013
*
* This file is part of free software framework for embedded processors.
* You can use it and/or distribute it as long as this copyright header
* remains unmodified. The code is free for personal use and requires
* permission to use in a commercial product.
*
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
@vlsi1217
vlsi1217 / MCM
Created February 12, 2014 00:09
lesson 4: Move Coverage to Monitor
GUIDANCE
Add coverage from cur_pkt inside the monitor
Items: length, packet_kind
Transition: length
SYNTAX
Reference fields from struct
item ITEM_NAME : TYPE = OBJECT_NAME.FIELD_NAME;
@vlsi1217
vlsi1217 / PIM
Created February 12, 2014 00:05
solution for lesson 4: Port ID Monitor
GUIDANCE
Use when sub typing to connect to the right signals of the signal map.
A new enum was added to identify the port (value is controlled during
generation).
Use the port_name field (which is of this new enum type) to select
which signals of the smp the signals of the monitor need to be
connected to. See example for the IN packet_monitor_u for reference
@vlsi1217
vlsi1217 / lesson4_PR
Last active August 29, 2015 13:56
Packet Recreation for lesson 4 of Udacity: functional Hardware verification
GUIDANCE
Recreate/reconstruct a packet_s from list of bytes collected
- complete the recreate_pkt() method below
- pull proper values from the list
<'
unit packet_monitor_u{
!smp: router_signal_map_u;
@vlsi1217
vlsi1217 / Watch Interface Method
Created February 10, 2014 10:01
solution for Udacity: functional hardware verification: lesson 4: connecting the signal map
GUIDANCE
Fill in TCM to collect packet information from DUT
<'
unit packet_monitor_u {
!smp: router_signal_map_u;
!cur_pkt: packet_s;
@vlsi1217
vlsi1217 / packet_monitor
Created February 10, 2014 09:44
solution for Udacity: functional hardware verification: lesson 4: connecting the signal map
GUIDANCE
1. Instantiate signal map - name it smp
2. Print value of valid, data, suspend of ouput port 0
by referencing signal map
SYNTAX
Do not randomize signal map unit
!map_instance_name: map_def_name_u;