OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [utils/] [bin2vlogarray.c] - Rev 373

Go to most recent revision | Compare with Previous | Blame | View Log

/*$$HEADER*/
/******************************************************************************/
/*                                                                            */
/*                    H E A D E R   I N F O R M A T I O N                     */
/*                                                                            */
/******************************************************************************/
 
// Project Name                   : ORPSoC v2
// File Name                      : bin2vlogarray.c
// Prepared By                    : 
// Project Start                  : 
 
/*$$COPYRIGHT NOTICE*/
/******************************************************************************/
/*                                                                            */
/*                      C O P Y R I G H T   N O T I C E                       */
/*                                                                            */
/******************************************************************************/
/*
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; 
  version 2.1 of the License, a copy of which is available from
  http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
 
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
 
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/
 
/*$$DESCRIPTION*/
/******************************************************************************/
/*                                                                            */
/*                           D E S C R I P T I O N                            */
/*                                                                            */
/******************************************************************************/
//
// Generate verilog lines assigning array output from binary final input
//
// Looks like this:
//
// 0 : wb_dat_o <= 32'h18000000;
// 1 : wb_dat_o <= 32'h18200000;
// 2 : wb_dat_o <= 32'h1880b000;
// 3 : wb_dat_o <= 32'ha8400051;
// 4 : wb_dat_o <= 32'hd8041000;
// 5 : wb_dat_o <= 32'h18c00000;
// 6 : wb_dat_o <= 32'h18e00000;
//
// etc...
//
// The generated file is pulled into the appropriate part of a verilog 
// module and gets synthesized.
 
#include <stdio.h>
#include <stdint.h>
 
#define OUT_REG_STRING "wb_dat_o"
 
// OR1200 no longer has these #delays on synchronous assigns - so we don't need
// them here anymore either.
//#define ASSIGN_STRING "<= #1"
#define ASSIGN_STRING "<= "
 
#define SIZE_STRING "32'h"
 
// Concatenate the defines 
#define BEFORE_STRING "%d : "OUT_REG_STRING" "ASSIGN_STRING" "SIZE_STRING
 
//#define BEFORE_STRING "%d : wb_dat_o <= 32'h"
 
 
int main(void)
{
 
  int c, word_counter=0;
  uint32_t word;
  uint8_t *wordarray = (uint8_t*) &word;
 
  while((c = getchar()) != EOF) {
    /* Endianess might change things here */
    wordarray[3] = c;
    wordarray[2] = getchar();
    wordarray[1] = getchar();
    wordarray[0] = getchar();
    printf(BEFORE_STRING, word_counter);
    printf("%.8x;\n", word);
    word_counter++;
  }
 
  return(0);
 
}
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.